Returns the name of the currently executing program, procedure, or user-defined function (UDF).

Syntax

PROGRAM([<expN>])

<expN>

Any number.

Description

PROGRAM( ) returns the name of the lowest level executing subroutine—program, procedure, or UDF. PROGRAM( ) returns an empty string ("") when no program or subroutine is executing.

PROGRAM(expN) returns the full path name of the program that is currently running, which may be different from the name of the lowest level executing subroutine. This is shown in the following example.

SET PROCEDURE TO program1
** Inside PROGRAM1.PRG is PROCEDURE procedure1
** If procedure1 is running, note the following:
? PROGRAM( ) returns PROCEDURE1
? PROGRAM(expN) returns C:\Program Files\dBASE\Plus\My Programs\PROGRAM1.PRG.

You can issue PROGRAM( ) in the Command window if a program is suspended with SUSPEND. For example, if Program A calls Procedure B, and Procedure B is suspended, issuing PROGRAM( ) in the Command window returns the name of Procedure B; issuing PROGRAM(expN) in the Command window returns the full path name of the file containing Procedure B.

You can also use PROGRAM( ) with ON ERROR and LINENO( ) to identify the subroutine that was executing and the exact program line number at which the error occurred.

PROGRAM( ) returns the name of the subroutine in uppercase letters. PROGRAM( ) doesn't include a file-name extension even if the subroutine is a separate file, while PROGRAM(expN) always includes a file-name extension.