Click to Rate and Give Feedback
MSDN
MSDN Library
Visual FoxPro
Reference
Language Reference
Functions
 PROGRAM( ) Function

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
Visual FoxPro 9.0 SP2
PROGRAM( ) Function

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.

PROGRAM([nLevel])

Parameters

nLevel

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 Visual FoxPro 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 PROGRAM(–1) in the Command window always returns zero (0).

If nLevel exceeds the program nesting depth, PROGRAM( ) returns an empty string ("").

Character or Numeric. PROGRAM( ) returns a program name, the number of the current program level, or an empty string.

You can use PROGRAM( ) to help your program recover from errors. The PROGRAM( ) function is similar to SYS(16) - Executing Program File Name.

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
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker