The DO command makes an entry in the GT.M invocation stack and transfers execution to the location specified by the entryref.
The format of the DO command is:
D[O][:tvexpr] [entryref[(expr|.lvn[,...])][:tvexpr][,...]]
The optional truth-valued expression immediately following the command is a command postconditional that controls whether or not GT.M executes the command.
The optional entryref specifies a location (with some combination of label, offset, and routinename) at which execution continues immediately following the DO.
A DO command without an argument (that is, a DO followed by two (2) spaces) transfers execution to the next line in the routine if that line contains a number of periods (.) after the optional label and before the required linestart. These periods indicate the current level of "immediate" nesting caused by argumentless DOs. If the line following the DO contains too many periods, GT.M reports an error; if the line following the DO contains too few periods, GT.M ignores the DO command.
A DO command without an argument stacks the current value of $TEST, in contrast to a DO with an argument, which does not protect the current value of $TEST.
The optional parameter list enclosed in parentheses ( ) contains parameters to pass to the routine entry point.
If the DO specifies a parameter list, the entryref location must start with a label and an argument list (that is, GT.M prohibits entryrefs with offsets during parameter passing).
If an element in the parameter list starts with a period, it specifies an unsubscripted local variable name and the DO passes that variable by reference. Otherwise, the element specifies an expression that the DO evaluates and passes as a value.
The optional truth-valued expression following the parameter list, or the entryref if the argument contains no parameter list, specifies the argument postconditional and controls whether GT.M performs a DO with that argument.
An indirection operator and an expression atom evaluating to a list of one or more DO arguments form a legal argument for a DO.
An explicit or implicit QUIT within the scope of the DO, but not within the scope of any other DO, FOR, XECUTE, or extrinsic, returns execution to the instruction following the calling point. This point may be the next DO argument or another command. At the end of a routine, or the end of a nesting level created by an argumentless DO, GT.M performs an implicit QUIT. Any line that reduces the current level of nesting by changing the number of leading periods (.) causes an implicit QUIT, even if that line only contains a comment.
Terminating the image and execution of ZGOTO commands are the only ways to avoid eventually returning execution to the calling point. A DO command may optionally pass parameters to the invoked subroutine.
For more information about entryrefs and parameterpassing, refer to the "General Language Features of M" chapter in this manual.