EOF

The EOF function tests the specified file unit for the end-of-file condition. If the file pointer is positioned at the end of the file, EOF returns true (1), otherwise false (0) is returned.

Note that the EOF function cannot be used with files opened with the NOSTDIO keyword to the OPEN routines. Many of the devices commonly used with NOSTDIO signal their end-of-file by returning a zero transfer count to the I/O operation that encounters the end-of-file.

Calling Sequence

Result = EOF( Unit )

Arguments

Unit

The file unit to test for end-of-file.

Using EOF with VMS Files

Under VMS, the EOF function does not work with files accessed via DECNET or that do not have sequential organization (i.e., relative or indexed). The EOF procedure cannot be used with such files as it will always return "false". Instead, use the ON_IOERROR procedure to detect when the end-of-file occurs.

Examples

If file unit number 1 is open, the end-of-file condition can be checked by examining the value of the expression EOF(1). For example, the following IDL code reads and prints a text file:

OPENR, 1, 'test.lis' ; Open the file test.lis.

A = '' ; Define a string variable.

WHILE NOT EOF(1) DO BEGIN ; Loop until EOF is found.

    READF, 1, A ; Read a line of text.

    PRINT, ; Print the line.

    ENDWHILE

CLOSE, 1 ; Close the file.

See Also

POINT_LUN