User Tools

Site Tools


eof_return_end_of_file_.htm
Navigation:  Language Reference > App E - Legacy Statements >====== EOF (return end of file) C6H0007.jpg ====== Previous pageReturn to chapter overviewNext page

EOF(file)

blk2blue.jpg

EOF Flags the end of the FILE during sequential processing.
file The label of a FILE declaration.

The EOF procedure returns a non-zero value (true) when the last record in relative file sequence has been read by NEXT or passed by SKIP. Otherwise, the return value is zero (false).

The EOF procedure is not supported by all file drivers, and can be very inefficient even if supported (check the driver documentation). Therefore, for efficiency and guaranteed file system support it is not recommended to use this procedure. Instead, check the ERRORCODE() procedure after each disk read to detect an attempt to read past the end of the file.

The EOF procedure was most often used as an UNTIL condition at the top of a LOOP, so EOF returns true after the last record has been read and processed.

Return Data Type:     LONG

Example:

!Not recommended, and still available for backward compatibility:

SET(Trn:DateKey)            !Beginning of file in keyed sequence

LOOP UNTIL EOF(Trans)       !Process all records

NEXT(Trans)                ! read a record sequentially

IF ERRORCODE() THEN STOP(ERROR()).

DO LastInFirstOut          ! call last in first out routine

END  

!Recommended for use with all file drivers:

SET(Trn:DateKey)            !Beginning of file in keyed sequence

LOOP                        !Process all records

NEXT(Trans)                ! read a record sequentially

IF ERRORCODE() THEN BREAK. !Break loop on attempt to read past end of file

DO LastInFirstOut          ! call last in first out routine

END  

See Also:

ERRORCODE

eof_return_end_of_file_.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1