Open a text file to allow appending of text to the end System unit
 procedure Append(var FileHandle TextFile);
The Append procedure opens a file given by FileHandle to allow subsequent writes to append to the end of the file.
You must use AssignFile to assign a file to the FileHandle before using Append.
This is often used when logging information - existing log data must be preserved, with the new log information appended to the end.
Use Write or WriteLn to write to the file after this Append is executed.
Related commands
AssignFileAssigns a file handle to a binary or text file
TextFileDeclares a file type for storing lines of text
WriteWrite data to a binary or text file
WriteLnWrite a complete line of data to a text file
 Download this web site as a Windows program.

Example code : Appending a line of text to an existing file
  myFile : TextFile;
  text   : string;

  // Try to open the Test.txt file for writing to
  AssignFile(myFile, 'Test.txt');

  // Write a couple of well known words to this file
  WriteLn(myFile, 'Hello');
  WriteLn(myFile, 'World');

  // Close the file

  // Reopen to append a final line to the file

  // Write this final line
  WriteLn(myFile, 'Final line added');

  // Close the file

  // Reopen the file for reading

  // Display the file contents
  while not Eof(myFile) do
    ReadLn(myFile, text);

  // Close the file for the last time
Show full unit code
  Final line added
Delphi Programming © Neil Moffatt . All rights reserved.  |  Home Page