$ZTRAP Behavior

If, at the time of any error, the value of $ZTRAP is non-empty, GT.M uses the $ZTRAP contents to direct execution of the next action. Refer to the $ZTRAP section in the "Intrinsic Special Variables" chapter in this manual.

By default, execution proceeds as if the next instruction to be executed were the first one on "the next line", and the code on that next line would be the same as the text in the value of $ZTRAP. Unless there is a GOTO or ZGOTO, after the code in $ZTRAP has been executed, GT.M attempts to execute the line with the error again. When a value is assigned to $ZTRAP, the new value replaces the previous value. If the value of $ETRAP is a non-empty one, $ETRAP is implicitly NEWed, and the value of $ETRAP becomes equal to the empty string; this ensures that at most one of $ETRAP and $ZTRAP is not the empty string. If the logical name gtm_ztrap_new evaluates to boolean TRUE (case insensitive string "TRUE", or case insensitive string "YES", or a non-zero number), $ZTRAP is NEWed when $ZTRAP is SET; otherwise $ZTRAP is not stacked when it is SET.

In addition to the default behavior, $ZTRAP has a number of different modes of operation controlled by the logical name gtm_ztrap_form described in the following table.

gtm_ztrap_form

$ZTRAP and EXCEPTION Behavior  

code

Content is code executed after the error; in the absence of GOTO, ZGOTO, or QUIT, execution resumes at the beginnig of the line containing the error - default behavior

entryref

Content is an entryref to which control is transferred by an implicit GOTO

adaptive

If content is valid code treat it as described for "code", otherwise attempt to treat it as an entryref

popentryref

Content is entryref - remove M virtual stack levels until the level at which $ZTRAP was SET, then GOTO the entryref; the stack manipulation occurs only for $ZTRAP and not for EXCEPTION

popadaptive

If content is valid code treat it as described for code, otherwise attempt to treat it as an entryref used as described for popentryref

Although the "adaptive" and "popadaptive" behaviors permit mixing of two behaviors based on the current value of $ZTRAP, the $ZTRAP behavior type is selected at process startup from gtm_ztrap_form and cannot be modified during the life of the process.