The ZPRINT command displays the source code lines selected by its argument.
The format of the ZPRINT command is:
The optional truth-valued expression immediately following the command is a command postconditional that controls whether or not GT.M executes the command.
A ZPRINT with no argument prints the entire current routine or the current trigger. The current routine is the routine closest to the top of an invocation stack, as displayed by a ZSHOW "S"; in this case, at least two (2) spaces must follow the command to separate it from the next command on the line.
The optional entryref specifies the location in a routine at which to start printing; the entryref can include either a routinename or a label plus a routinename in the format LABEL^ROUTINENAME or LABEL+OFFSET^ROUTINENAME; if the entryref does not contain a routinename, ZPRINT defaults to the current routine.
The optional label following the entryref identifies a location at which to stop printing; the optional integer expression specifies an offset from the label; the label and offset together are referred to as a lineref and this lineref identifies the last line to print; if the offset is specified without the label, the offset in the optional lineref is always counted from the beginning of the routine, even when the entryref specifies a label.
If the ZPRINT argument includes the colon (:) delimiter, then the argument must also include at least one component of the optional lineref.
If the ZPRINT argument contains only the entryref, with no components of the optional lineref and the entryref contains a label or offset, ZPRINT displays only the one line that occurs at that entryref.
If the entryref contains only a routinename, ZPRINT displays the entire routine.
If the entryref contains a trigger name, ZPRINT displays its trigger code.
If the entryref contains only a routinename and the argument includes the optional lineref, ZPRINT starts the display at the beginning of the routine.
If the optional lineref specifies a line prior to the lineref specified within the entryref, ZPRINT does not display any lines.
If the offset in the optional lineref specifies a line beyond the end of the routine, ZPRINT displays the remainder of the routine.
If ZPRINT cannot locate the routine or if either of the labels does not appear in the routine, ZPRINT issues an error.
An indirection operator and an expression atom evaluating to a list of one or more ZPRINT arguments form a legal argument for a ZPRINT.
Note that the routinename may only appear before the colon (:) delimiter. The integer expression offsets may be positive or negative, but they must always be delimited by a plus sign (+).
For more information on entryrefs, refer to Chapter 5: “General Language Features of M”.
This example displays the line beginning with the label X in the routine RTN.
GTM>ZPRINT X^RTN:X+5 GTM>ZPRINT X+-5^RTN:X GTM>ZPRINT X^RTN:X+-5^RTN
The first line displays the line beginning with the label X and the next 5 lines in routine RTN. The second line displays the 5 lines preceding label X in the same routine and the line beginning with label X. The third line generates a run-time error because the routine name must appear only before the colon in the argument.
GTM>zprint ^A#1# do ^test1 do stop^test2 GTM>
This command displays the trigger code for trigger name A#1#.
ZPRINT ^x#/BREG : Print trigger routine user-named "x" in region BREG ZPRINT ^x#1#/BREG : Print trigger routine auto-named "x#1" in region BREG ZPRINT ^x#1#A/BREG : Print trigger routine auto-named "x#1", runtime disambiguated by "#A", AND in region BREG ZPRINT +1^x#1#A/BREG : Print line 1 of trigger routine auto-named "x#1", runtime disambiguated by "#A", AND in region BREG
These are some examples of disambiguator combinations.