From Clomosy Docs
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
<div class="alert alert-ligth border border-3 border-primary-subtle rounded-5 p-4 shadow-sm" role="alert"> | |||
function Eof(var FileHandle TextFile); | |||
</div> | |||
The Eof function returns true if the file given by FileHandle is at the end. | |||
<div class="alert alert-danger" role="alert" data-bs-theme="light"> | |||
myFile : TextFile; | The file must have been assigned, and opened with [[Reset]]. | ||
</div> | |||
<b>Example</b><br> | |||
<pre> | |||
var | |||
myFile : TextFile; | |||
{ | |||
AssignFile(myFile, 'Test.txt'); | AssignFile(myFile, 'Test.txt'); | ||
ReWrite(myFile); | ReWrite(myFile); | ||
WriteLn(myFile, 'Hello'); | WriteLn(myFile, 'Hello'); | ||
WriteLn(myFile, 'World'); | WriteLn(myFile, 'World'); | ||
CloseFile(myFile); | CloseFile(myFile); | ||
Reset(myFile); | Reset(myFile); | ||
while not | |||
while (not Eof(myFile)) | |||
{ | |||
ReadLn(myFile); | ReadLn(myFile); | ||
} | |||
CloseFile(myFile); | CloseFile(myFile); | ||
} | |||
</pre> | |||
<h2> See Also </h2> | |||
* [[File_Handling | File Handling]] | |||
Revision as of 15:17, 23 October 2024
function Eof(var FileHandle TextFile);
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.
Example
var
myFile : TextFile;
{
AssignFile(myFile, 'Test.txt');
ReWrite(myFile);
WriteLn(myFile, 'Hello');
WriteLn(myFile, 'World');
CloseFile(myFile);
Reset(myFile);
while (not Eof(myFile))
{
ReadLn(myFile);
}
CloseFile(myFile);
}