Navigation: Language Reference > 12 - Execution Control > Execution Control Statements >====== GOTO (go to a label) ====== | |
GOTO target
GOTO | Unconditionally transfers program control to another statement. |
target | The label of another executable statement within the PROGRAM, PROCEDURE, or ROUTINE. |
The GOTO statement unconditionally transfers control from one statement to another. The target of a GOTO must not be the label of a ROUTINE or PROCEDURE.
The scope of GOTO is limited to the currently executing ROUTINE or PROCEDURE–it may not target a label outside the ROUTINE or PROCEDURE in which it is used.
Extensive use of GOTO is generally not considered good structured programming practice. LOOP is usually considered a better alternative.
Example:
ComputeIt PROCEDURE(Level)
CODE
IF Level = 0
GOTO PassCompute !Skip rate calculation if no Level
END
Rate = Level * MarkUp !Compute Rate
RETURN(Rate) !and return it
PassCompute RETURN(999999) !Return bogus number
See Also: