ENDFILE condition

Indicates that an attempt was made to read past the end of the file specified in the GET or READ statement.

Enabled/Disabled status

Always enabled.

Result

If the specified file is not closed after the condition is raised, this causes subsequent GET or READ statements to the file to be unsuccessful, and also raises additional ENDFILE conditions.

Important: Do not close the file in its ENDFILE ON-unit. Instead, close it only after that ON-unit has been exited.

Raised

During an operation when an attempt is made to read past the end of the file specified in the GET or READ statement. The ENDFILE condition applies only to SEQUENTIAL INPUT, SEQUENTIAL UPDATE, and STREAM INPUT files.

ENDFILE is also raised during record-oriented data transmission when an end-of-file is encountered during the execution of a READ statement.

Finally, ENDFILE is raised in stream-oriented data transmission during the execution of a GET statement if an end-of-file is encountered either before any items in the GET statement data list have been transmitted or between transmission of two of the data items. If an end-of-file is encountered while a data item is being processed, or if it is encountered while an X-format item is being processed, the ERROR condition is raised.

Syntax

ENDFILE [file-reference]

Parameter

file-reference
A scalar reference; if omitted, assumed SYSIN.

Other information

Condition code
70
Implicit action
Prints a message and raises the ERROR condition.
Normal return
Returning from the ON-unit transfers control to the statement following the GET or READ statement.