PROGRAM( ) Function
Returns the name of the program currently executing, the current program level, or the name of the program executing when an error occurred.
PROGRAM([nLevel])
Return Values
Character or Numeric
Parameters
nLevel
Specifies how many program levels back the program name is to be found. This parameter can range from 0 to the program nesting depth. A program can execute another program, which can execute another program, and so on. Programs may be nested to 128 levels.If you specify 0 or 1 for nLevel, PROGRAM( ) returns the name of the master program (the highest-level program). If nLevel exceeds the program nesting depth, PROGRAM( ) returns an empty string.
If you specify –1 for nLevel, PROGRAM( ) returns as a numeric value the current program level. PROGRAM(–1) always returns zero when issued from the Command window.
Remarks
PROGRAM( ) helps your program recover from errors. It is similar to SYS(16).
If used without an argument, PROGRAM( ) returns the name of the currently executing program.
Example
ON ERROR DO errhand WITH PROGRAM( )
** The next line should generate an error ** USE nodatabase ON ERROR && Returns to system default error-handling routine PROCEDURE errhand PARAMETERS gcProgram WAIT 'An error occurred in the program ' + gcProgram WINDOW
See Also
DO | LINENO( ) | MESSAGE( ) | SYS(16) – Executing Program File Name | ASTACKINFO( )