G (also GO or GOTO)

Unconditionally transfers program control to a command line within the Proc beginning with the specified label.

Syntax

G label

GO label

GOTO label

Syntax Elements

label specifies the command where Proc execution is to continue.

label is a number at the start of the line containing the command to be executed, separated from the command by at least one space.

Operation

All three forms of the command are equivalent and cause Proc execution to continue with the statement specified by label.

The Proc processor scans from the beginning of the current Proc to find the statement with the specified label. If the label cannot be found, execution stops, and an error message is displayed.

If the same label occurs more than once, only the first occurrence is executed. Multiple labels cause compilation errors if the Proc optimizer is used. Refer to the explanation of the PQ-COMPILE command.

In the case of multivalued comparisons, instead of repeating GO in each multivalued command, just use GO once, followed by the labels separated by value marks (X'FD'). For example:

IF A = A]B]25]50 GO 10]20]30]40

Example 1

001 PQN
002 F-OPEN 3 "INV"
003 G 30
004 T C,(10,10),"Enter the item-id",S5,+
.
.
020 30 XCannot open INV file

This example transfers control to the statement with label 30 if the INV file cannot be opened.

Example 2

001 PQN
002 5 T C,(10,10),"Type L for LIST or S for SORT:
     (<<CR>> to END)",S5,+
003 IP %1
004 IF %1 = L]S]"" GO 10]GO 20]XEND OF JOB
005 GOTO 5
.
.
011 10 T (10,),"Name of file to LIST?",S5,+
.
.
016 20 T (10,),"Name of file to SORT?",S5,+
.
.
.

This example transfers control to label 10 if LIST is chosen and to label 20 if SORT is chosen.

Pressing RETURN terminates the Proc with the message "END OF JOB". If the response is none of these, control transfers back to label 5.