$ZLevel
$ZLevel
$ZL[EVEL] contains an integer value indicating the “level of nesting” caused by DO commands, XECUTE commands, and extrinsic functions in the M invocation stack.
$ZLEVEL has an initial value of one (1) and increments by one with each DO, XECUTE or extrinsic function. Any QUIT that does not terminate a FOR loop decrements $ZLEVEL. ZGOTO may also reduce $ZLEVEL. In accordance with the M standard, a FOR command does not increase $ZLEVEL. M routines cannot modify $ZLEVEL with the SET or NEW commands.
Use $ZLEVEL in debugging or in an error-handling mechanism to capture a level for later use in a ZGOTO argument.
Example:
GTM>zprint ^zleve
zleve;
do B
write X,!
quit
B
goto C
quit
C
do D
quit
D
set X=$ZLEVEL
quit
GTM>do ^zleve
4
GTM>This program, executed from Direct Mode, produces a value of 4 for $ZLEVEL. If you run this program from the shell, the value of $ZLEVEL is three (3).