Kbase P97601: How to retrieve the name of the caller procedure?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  11/26/2004 |
|
Status: Verified
GOAL:
How to retrieve the name of a caller procedure?
GOAL:
How the PROGRAM-NAME function works?
GOAL:
What the PROGRAM-NAME function returns?
FIX:
PROGRAM-NAME function returns the name of the calling program.
Syntax:
PROGRAM-NAME( n )
Where:
n is the numeric argument. If n is 1, the name of the current program is returned. If n is 2, the name of the calling program is returned. If there is no calling program then you have reached the top of the call stack and Progress returns the unknown value (?).
Example:
This procedure returns the names of any procedure(s) that called it, and displays the number of levels that the procedure was nested.
/* Note this program should be run as a subroutine */
/* The deeper the nesting, the better the illustration */
DEFINE VAR level AS INT INITIAL 1.
REPEAT WHILE PROGRAM-NAME(level) <> ?.
DISPLAY LEVEL PROGRAM-NAME(level) FORMAT "x(30)".
level = level + 1.
END.