Unit 'System' Package
[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] [#rtl]

EOF

Check for end of file.

Declaration

Source position: systemh.inc line 1416

function EOF(

  var f: file

):Boolean;

function EOF(

  var t: Text

):Boolean;

function EOF: Boolean;

Description

Eof returns True if the file-pointer has reached the end of the file, or if the file is empty. In all other cases Eof returns False. If no file F is specified, standard input is assumed.

Note that calling this function may cause your program to wait: to determine whether you are at EOF, it is necessary to read data. If the file descriptor is not a real file (for instance for standard input or sockets), then this call may seem to hang the program while it is waiting for data to appear or for the file descriptor to be closed.

Errors

Depending on the state of the {$I} switch, a runtime error can be generated if there is an error. In the {$I-} state, use IOResult to check for errors.

See also

Eoln

  

Check for end of line.

Assign

  

Assign a name to a file.

Reset

  

Open file for reading.

Rewrite

  

Open file for writing.

Example

Program Example18;

{ Program to demonstrate the Eof function. }

Var T1,T2 : text;
    C : Char;

begin
  { Set file to read from. Empty means from standard input.}
  assign (t1,paramstr(1));
  reset (t1);
  { Set file to write to. Empty means to standard output. }
  assign (t2,paramstr(2));
  rewrite (t2);
  While not of1) do
    begin
    read (t1,C);
    write (t2,C);
    end;
  Close (t1);
  Close (t2);
end.

Documentation generated on: Oct 27 2024