ONFILE Function

Purpose

Returns the name of a file constant for which the most recent ENDPAGE, ENDFILE, KEY, or UNDEFINEDFILE condition was signaled.

Syntax

ONFILE()

Description

The ONFILE function returns the name of a file constant for which the most recent ENDPAGE, ENDFILE, KEY, or UNDEFINEDFILE condition was signaled. The ONFILE function can also be used in an ERROR ON-unit that gets control as a consequence of the default Open PL/I action for file-related errors. (The default action for file-related errors is to signal the ERROR condition.)

The returned value is a varying length character string.

On some systems, you may need to specify the -defext compile-time option for ONFILE to return the correct value. For specific information, see your Open PL/I User's Guide.

Restrictions

If referenced outside an ON-unit or within an ON-unit that is executed as a result of a SIGNAL statement, the ONFILE function returns a null string.

If used outside an ON-unit or within an ON-unit that has been invoked as the result of a condition unrelated to any file, the ONFILE function returns a null string.

All other uses of such files must be in other modules compiled without the -defext compile-time option or declared with the GLOBALREF attribute.