The Eof function returns true if the file given by FileHandle is at the end.
The file must have been assigned, and opened with Reset.
|Warning after reading the last line of a file, Eof will be true, even though data has been read successfully.
So use Eof before reading, to see if reading is required.
|BlockRead||Reads a block of data records from an untyped binary file|
|Eoln||Returns true if the current text file is pointing at a line end|
|Read||Read data from a binary or text file|
|ReadLn||Read a complete line of data from a text file|
|SeekEof||Skip to the end of the current line or file|
|SeekEoln||Skip to the end of the current line or file|
| Download this web site as a Windows program.
|Example code : Reading to the end of a text file|
myFile : TextFile;
text : string;
// Try to open the Test.txt file for writing to
// Write a couple of well known words to this file
// Close the file
// Reopen the file in read only mode
// Display the file contents
while not Eof(myFile) do
// Close the file for the last time
|Show full unit code|