From Clomosy Docs

(Created page with " function Eof(TextFile); The Eof function returns true if the file given by FileHandle is at the end.<br> The file must have been assigned, and opened with Reset. '''Example:'''<br> '''var''' myFile : TextFile;<br> '''begin''' AssignFile(myFile, 'Test.txt'); ReWrite(myFile);<br> WriteLn(myFile, 'Hello'); WriteLn(myFile, 'World'); CloseFile(myFile); Reset(myFile);<br> while not '''Eof'''(myFile) do begin ReadLn(myFile); end;<br> Cl...")
 
No edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
function Eof(TextFile);
<div class="alert alert-ligth border border-3 border-primary-subtle rounded-5 p-4 shadow-sm" role="alert">
The Eof function returns true if the file given by FileHandle is at the end.<br>  
function Eof(var FileHandle TextFile);
The file must have been assigned, and opened with Reset.
</div>


'''Example:'''<br>
The Eof function returns true if the file given by FileHandle is at the end.
'''var'''
 
   myFile : TextFile;<br>
<div class="alert alert-danger" role="alert" data-bs-theme="light">
  '''begin'''
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);<br>
   ReWrite(myFile);
   WriteLn(myFile, 'Hello');
   WriteLn(myFile, 'Hello');
   WriteLn(myFile, 'World');
   WriteLn(myFile, 'World');
   CloseFile(myFile);
   CloseFile(myFile);
   Reset(myFile);<br>
   Reset(myFile);
   while not '''Eof'''(myFile) do
   begin
   while (not Eof(myFile))
   {
     ReadLn(myFile);
     ReadLn(myFile);
   end;<br>
   }
   CloseFile(myFile);
   CloseFile(myFile);
  '''end;'''
  }
</pre>
 
<h2> See Also </h2>
* [[File_Handling | File Handling]]
{{#seo:|title=EOF Using in Clomosy - Clomosy Docs}}
{{#seo:|description=EOF checks if the given file handle is at the end of the file, returning true if it is.}}

Latest revision as of 14:04, 24 December 2024

The Eof function returns true if the file given by FileHandle is at the end.

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);
 }

See Also