Stepping Through a Routine

The ZSTEP command provides a powerful tool to direct GT.M execution. When you issue a ZSTEP from Direct Mode, GT.M executes the program to the beginning of the next target line and performs the ZSTEP action.

The optional keyword portion of the argument specifies the class of lines where ZSTEP pauses its execution, and XECUTEs the ZSTEP action specified by the optional action portion of the ZSTEP argument. If the action is specified, it must be an expression that evaluates to valid GT.M code. If no action is specified, ZSTEP XECUTEs the code specified by the $ZSTEP intrinsic special variable; by default $ZSTEP has the value "B", which causes GT.M to enter Direct Mode.

ZSTEP actions, that include commands followed by a BREAK, perform the specified action, then enter Direct Mode. ZSTEP actions that do not include a BREAK perform the command action and continue execution. Use ZSTEP actions that issue conditional BREAKs and subsequent ZSTEPs to perform tasks such as test for changes in the value of a variable.

Use ZSTEP to incrementally execute a routine or a series of routines. Execute any GT.M command from Direct Mode at any ZSTEP pause. To resume normal execution, use ZCONTINUE. Note that ZSTEP arguments are keywords rather than expressions, and they do not allow indirection.

Example:

        GTM>ZSTEP INTO
        %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action
        At M source location print^DMEX
        GTM>ZSTEP OUTOF
        Paul Revere
        Name: Q
        %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action
        At M source location name^DMEX
        GTM>ZSTEP OVER
        %GTM-I-BREAKZST, Break instruction encountered during ZSTEP action
        At M source location name+1^DMEX
        

This shows using the ZSTEP command to step through the routine DMEX starting where execution was interrupted by the undefined variable error. The ZSTEP INTO command executes line name+3 and then interrupts execution at the beginning of line "print".

The ZSTEP OUTOF continues execution until line name. The ZSTEP OVER, which is the default, executes until it encounters the next line at this level on the M invocation stack. In this case, the next line is name+1. The ZSTEP OVER could be replaced with a ZSTEP with no argument because they do the same thing.