MSI Factory 2.3

TextFile.WriteFromTable

TextFile.WriteFromTable

This is the first topic This is the last topic  

TextFile.WriteFromTable

This is the first topic This is the last topic  

OverviewExamples

TextFile.WriteFromTable (

string Filename,

table   Table,

boolean Append = false )

Example 1

TextFile.WriteFromTable(_TempFolder .. "\\Information.txt", table_input, false);

Writes out the contents of the "table_input" table to the file "Information.txt" located in the user's temporary folder. The table consists of one line of text per table item. Any current text within "Information.txt" will be overwritten.

Note: _TempFolder is a built-in variable that contains the path to the user's system "Temp" folder.

Example 2

TextFile.WriteFromTable(_TempFolder .. "\\Information.txt", table_input, true);

Appends the contents of the "table_input" table to the file "Information.txt" located in the user's temporary folder. The table consists of one line of text per table item.

Note: _TempFolder is a built-in variable that contains the path to the user's system "Temp" folder.

Example 3

-- 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