Flushes buffered text file data to the file System unit
 procedure Flush(var FileHandle TextFile);
The Flush procedure flushes unwritten text file data to disk.
The same effect can be achieved by closing the file. In fact, this is more likely to be effective, since Flush simply passes the flush request to the Operating System, which may in turn be doing its own buffering, and possibly caching.
Related commands
AssignFileAssigns a file handle to a binary or text file
CloseFileCloses an open file
FileDefines a typed or untyped file
TextFileDeclares a file type for storing lines of text
 Download this web site as a Windows program.

Example code : Flushing after writing lines to a 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 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
Delphi Programming © Neil Moffatt . All rights reserved.  |  Home Page