Click or drag to resize

Program Function

X#
Returns the name of the program at a specified program level, the name of the currently executing program, the current program level, or the name of the program executing when an error occurred.

Namespace:  XSharp.VFP
Assembly:  XSharp.VFP (in XSharp.VFP.dll) Version: 2.21
Syntax
 FUNCTION Program(
	nLevel,
	lShowSignature
) AS USUAL CLIPPER
Request Example View Source

Parameters

nLevel (Optional)
Type: Usual
Specifies the number of program levels to search for the program name. The nLevel parameter can range from 0 to the program nesting depth. For more information about program nesting levels, see maximum number of DO calls in X# System Capacities.
When nLevel is omitted, Program( ) returns the name of the currently executing program. If you specify 0 or 1 for nLevel, Program( ) returns the name of the master program, or the highest-level program.
If you specify –1 for nLevel, Program( ) returns the current program level as a numeric value. However, using codeProgram(–1)/code in the Command window always returns zero (0).
If nLevel exceeds the program nesting depth, Program( ) returns an empty string ("").
lShowSignature (Optional)
Type: Usual

Return Value

Type: Usual
Character or Numeric. Program( ) returns a program name, the number of the current program level, or an empty string.
Remarks
You can use Program( ) to help your program recover from errors. The Program( ) function is similar to SYS(16) - Executing Program File Name.
Examples
X#
1ON ERROR DO errhand WITH Program( )
2*** The next line should generate an error ***
3Use nodatabase
4ON ERROR     // Returns to system default error-handling routine
5PROCEDURE errhand
6PARAMETERS gcProgram
7WAIT 'An error occurred in the program ' + gcProgram WINDOW
See Also