MSI Factory 2.3

TextFile.ReadToTable

TextFile.ReadToTable

This is the first topic This is the last topic  

TextFile.ReadToTable

This is the first topic This is the last topic  

OverviewExamples

table TextFile.ReadToTable (

string Filename )

Example 1

text_table = TextFile.ReadToTable(_SourceDrive .. "\\Information.txt");

Reads the contents of the file "Information.txt" and stores each line in the table "text_table."

Example 2

-- Read the contents of a text file to a table.

text_contents = TextFile.ReadToTable("C:\\MyFile.txt");

 

-- Get the error code of the last action.

error = Application.GetLastError();

 

-- If an error occurred, display the error code message.

if (error ~= 0) then

   Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);

else

   -- Remove the second item in the table (second line in the text file).

   Table.Remove(text_contents, 2);

 

   -- Write out the modified text file.

   TextFile.WriteFromTable("C:\\MyFile.txt", text_contents, false);

 

   -- Get the error code of the last action.

   error = Application.GetLastError();

   -- If an error occurred, display the error code message.

   if (error ~= 0) then

       Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);

   end

end

Reads the contents of a text file to a table. The second table entry (second line) is then removed and written back to the text file overwriting its current contents.

See also: Related Actions


Learn More: Indigo Rose Software - MSI Factory - Buy Now - Contact Us