RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
System.SeekEof Function

Returns the end-of-file status of a file, ignoring whitespace.

Pascal
function SeekEof: Boolean; overload;
function SeekEof(var F: Text): Boolean; overload;
C++
Boolean SeekEof();
Boolean SeekEof(Text F);

In Delphi code, call SeekEof to determine whether there is only whitespace between the file pointer and the end of a file. SeekEof moves the file pointer past any whitespace, leaving it positioned at the end of a file or on the next non-whitespace character, whichever comes first. If it leaves the file pointer at the end of the file, SeekEof returns true. Otherwise, it returns false. 

SeekEof can only be used on open text files.

Note: {$I+} handles runtime errors using exceptions. When using {$I-}, use IOResult to check for I/O errors.
 

Delphi Examples: 

 

{
This example creates a file TEST.TXT, puts some text in it
and then reads the file to EOF.
}
procedure TForm1.Button1Click(Sender: TObject);
var
   f : System.TextFile;
   j, Y : Integer;
 begin
   AssignFile(f,'TEST.TXT');
   Rewrite(f);
   { Create a file with 8 numbers and some
     whitespace at the ends of the lines }
   Writeln(f,'1 2 3 4 ');
   Writeln(f,'5 6 7 8 ');
   Reset(f);
   { Read the numbers back. SeekEof returns TRUE if there is no 
     more text (other than whitespace) in the file. }
   Y := 5;
   while not SeekEof(f) do
   begin
     Read(f,j);
     Canvas.TextOut(5, Y, IntToStr(j));
     Y := Y + Canvas.TextHeight(IntToStr(j)) + 5;
   end;
 end;

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!