GOTO (Go To)
Purpose
The Go To (GOTO) command is used in CL programs for branching from one part of the program to another. The branching is to the label on another command that is specified on the GOTO command. Branching can be either forward or backward, but the specified label must be inside the program.
Restriction: This command is valid only within a CL program.
Required Parameters
- CMDLBL
- Specifies the label name of the command to which control is transferred when the GOTO command is processed. The command with the label is then processed. If the specified command cannot be run (for example, if it is a DCL command), control is transferred to the next command following the command with the specified label. The label must be within the same program as the GOTO command. A CL variable name cannot be used to specify the label name.
Example for GOTO
LOOP: CHGVAR &A (&A + 1) IF (&A *LT 30) THEN(GOTO LOOP)The Change Variable (CHGVAR) command increases the value of &A by 1 until &A is equal to or greater than 30. The GOTO command is processed each time that the IF command tests the expression and the result is true; the GOTO command following the THEN parameter causes the program to branch back to the label LOOP on the CHGVAR command. Refer to the descriptions of the CHGVAR command and the IF command for additional explanations of their functions.
Error messages for GOTO