Command reference / CL

GOTO

Go To

Used in a CL program or ILE CL procedure to branch from one part of the program to another. Control transfers to the labeled command given on GOTO. Branching can be forward or backward, but the label must be inside the program. For a GOTO in a subroutine, the branch target must be in the same subroutine.

Allowed environments: *BPGM, *IPGM. Use within a CL program. Positional parameters: 1.

Restrictions

Parameters

CMDLBL Command label

Specifies the label of the command to which control is transferred. If that command cannot be run (for example, a DCL command), control goes to the command after it. The label must be in the same program, and a CL variable cannot be used for the label name.

Type
*SNAME
Required
Yes
Length
10
Case
Uppercase

Examples

LOOP: CHGVAR &A (&A + 1)  /  IF (&A *LT 30) THEN(GOTO LOOP)

CHGVAR increases &A by 1 until &A is 30 or greater. Each time the IF test is true, GOTO branches back to the label LOOP on the CHGVAR command.

IBM command documentation

Generated from os/cl/catalog/GOTO.json and os/cl/help/GOTO.json.