Skip to the end of the current line or file System unit
 function SeekEof ( {var FileHandle : File} ) : Boolean;
The SeekEof procedure skips past white space characters in the current record in an open text file given by FileHandle.
The file must have been assigned with AssignFile and opened with Reset.
If the end of file (Eof) is thereby reached, the return value is True.
This function is normally used when reading unknown numbers of records in a file.
SeekEof is very similar to SeekEoln - the only difference is that SeekEof only returns true when Eof is reached; SeekEoln also returns true when the line end is reached after skipping the white spaces.
Related commands
Eof Returns true if a file opened with Reset is at the end
Eoln Returns true if the current text file is pointing at a line end
File Defines a typed or untyped file
FilePos Gives the file position in a binary or text file
Seek Move the pointer in a binary file to a new record position
SeekEoln Skip to the end of the current line or file
 Author links

 Download this web site as a Windows program.

Example code : Reading all records in a text file
  myFile : TextFile;
  number : Integer;

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

  // Write numbers in a string
  WriteLn(myFile, '1 2 3 4   ');   // White space at the end

  // Write numbers as separate parameters
  WriteLn(myFile, 5, ' ', 6, ' ', 7, ' ');  // Results in '5 6 7 ' text

  // Close the file

  // Reopen the file for reading

  // Display the file contents
  while not SeekEof(myFile) do
    // Read numbers one at a time
    ShowMessage('Start of a new line');
    while not SeekEoln(myFile) do
      Read(myFile, number);

    // Now move to the next line

  // Close the file for the last time
Show full unit code
   Start of a new line
   Start of a new line
Delphi Programming Neil Moffatt 2002 - 2020. All rights reserved.  |  Home Page