SteinSOFT.net
  Writing to a textfile

Have you ever wondered how to write in textfile without using a Memo or a Richedit? Here is the answer:

procedure WriteTXT(Sender: TObject);
var
  text: textfile;
begin
  assignfile(text,'filename.txt');  // Open file filename.txt 
  // If the file already exists you can:
  Reset(text); // erase the content of the file
  // or you can:
  // Rewrite(file); delete the file and recreate it
  Write(text,'Hello World'); // Adds 'Hello World' in the textfile
  WriteLn(text,'Shalom World'); // Feeds line and adds 'Shalom World'
  closefile(text); // Closes the file (IMPORTANT)
end;

If you have any questions, feel free to ask them in the message board. You can also visit my homepage - www.seck.lu - for some Delphi software written by me.

Copyright © by SteinSOFT