The GOTO command transfers execution to a location specified by its argument.
The format of the GOTO command is:
G[OTO][:tvexpr] entryref[: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 required entryref specifies the target location for the control transfer.
The optional truth-valued expression immediately following the entryref specifies the argument postconditional, and controls whether GT.M performs a GOTO with that argument.
Additional commands on a line following a GOTO do not serve any purpose unless the GOTO has a postconditional.
An indirection operator and an expression atom evaluating to a list of one or more GOTO arguments form a legal argument to a GOTO.
A GOTO command within a line following a FOR command terminates that FOR command.
For more information on entryrefs, refer to Chapter 5: “General Language Features of M”.
Example:
GTM>GOTO TIME+4
This GOTO command transfers control from Direct Mode to the line that is four (4) lines after the line labeled TIME (in the currently active routine). Using an offset is typically a debugging technique and rarely used in production code.
Example:
GOTO A:x<0,^A:x=0,A^B
This GOTO command transfers control to label A in the current routine, if x is less than zero (0), to routine ^A if x is equal to zero (0), and otherwise to label A in routine ^B. Once any of the transfers occurs, the rest of the arguments have no effect.