FUNCTIONS CORE

ProcName()

Return the name of a procedure or function in the call stack

Syntax

Signature
ProcName( [nLevel] ) --> cName

Arguments

nLevel

is the number of steps up the call stack. 0, the default, is the current routine, 1 is the routine that called it, and so on.

Return value

The routine name as an uppercase string, or "" when nLevel is above the first routine of the program.

Description

Without an argument, the compiler supplies the name of the routine that contains the call. With nLevel, the name is read from the call stack at run time. A method is named CLASS:METHOD.

Notes

The example prints "MAIN" and "S_SHOWNAME".

Example

ProcName.prg
PROCEDURE Main()

   QOut( ProcName() )
   s_ShowName()

RETURN

STATIC PROCEDURE s_ShowName()

   QOut( ProcName() )

RETURN

Output

MAIN
S_SHOWNAME

See also