Code: To read a file
#--------------------------------- # Method : fileRead # Author : T.Palani Selvam # Purpose : Read all contents of a file. # Parameters: String, contains file name. # # Returns : - Nil - # Caller : # Calls : - Nil - #---------------------------------- public function fileRead(in m_sFile) { auto iLine; auto sEachLine; auto sFileContent; printf("fileRead is going to process for " & m_sFile); file_open(m_sFile,FO_MODE_READ); iLine = 0; while(file_getline(m_sFile, sEachLine) == 0) { sFileContent = sFileContent & sEachLine; iLine++; printf(sEachLine); } #report_msg(sFileContent); #Line is too length file_close(m_sFile); } #end of fileRead(in m_sFile)
Code: To write info to a file
#------------------------------ # Method : fileWrite # Author : T.Palani Selvam # Purpose : Write Given inputs to a file. # Parameters: String, contains file name. # # Returns : - Nil - # Caller : # Calls : - Nil - #----------------------------- public function fileWrite(inout m_sFile) { auto iLine; auto sEachLine; auto iBool; auto null=""; printf("fileWrite is going to process for " & m_sFile); file_open(m_sFile, FO_MODE_WRITE); iLine = 0; do { sEachLine = create_input_dialog("Enter Input to write in " & m_sFile); if (sEachLine == null ) { #equals to NULL iBool = 0; } else { iBool = 1; iLine = iLine + 1; file_printf(m_sFile,"%s",sEachLine & "\r\n"); printf(sEachLine); } } while(iBool == 1); file_close(m_sFile); #Closing file } #end of fileWrite(in m_sFile)
Code: To Append info to a file
#----------------------------------- # Method : fileAppend # Author : T.Palani Selvam # Purpose : Write Given inputs to a file. # Parameters: String, contains file name. # # Returns : - Nil - # Caller : # Calls : - Nil - #---------------------------------- public function fileAppend(inout m_sFile) { auto iLine; auto sEachLine; auto iBool; auto null=""; printf("fileAppend is going to process for " & m_sFile); file_open(m_sFile, FO_MODE_APPEND); iLine = 0; do { sEachLine = create_input_dialog("Enter value to append in " & m_sFile); if (sEachLine == null ) { #equals to NULL iBool =0; } else { iBool = 1; iLine = iLine + 1; file_printf(m_sFile,"%s",sEachLine & "\r\n"); printf(sEachLine); } } while(iBool == 1); file_close(m_sFile); } #end of fileAppend(in m_sFile)
No comments:
Post a Comment