From Clomosy Docs

No edit summary
No edit summary
 
(2 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.
:'''Base Syntax'''
 
var
<div class="alert alert-danger" role="alert" data-bs-theme="light">
   myFile : TextFile;<br>
The file must have been assigned, and opened with [[Reset]].
  begin
</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>
:'''TRObject Syntax'''


  var
<h2> See Also </h2>
    myFile : TextFile;
* [[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.}}
    AssignFile(myFile, 'Test.txt');
    ReWrite(myFile);
 
    WriteLn(myFile, 'Hello');
    WriteLn(myFile, 'World');
    CloseFile(myFile);
    Reset(myFile);
 
    while (not '''Eof'''(myFile))
    {
      ReadLn(myFile);
    }
 
  CloseFile(myFile);
  }

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