The computed GO TO statement selects one statement label from a list, depending on the value of an integer or real expression, and transfers control to the selected one.
Parameter |
Description |
s |
Statement label of an executable statement |
e |
Expression of type integer or real |
Execution proceeds as follows:
e is evaluated first. It is converted to integer, if required.
If 1 £ e £ n, where n is the number of statement labels specified, then the eth label is selected from the specified list and control is transferred to it.
If the value of e is outside the range, that is, e < 1 or e > n, then the computed GO TO statement serves as a CONTINUE statement.
s must be in the same program unit as the GO TO statement.
The same statement label can appear more than once in a GO TO statement.
The statement control jumps to must be executable, not DATA, ENTRY, FORMAT, or INCLUDE.
Control cannot jump into a DO, IF, ELSE IF, or ELSE block from outside the block.
... GO TO ( 10, 20, 30, 40 ), N ... 10 CONTINUE ... 20 CONTINUE ... 40 CONTINUE
In the above example:
If N equals one, then go to 10.
If N equals two, then go to 20.
If N equals three, then go to 30.
If N equals four, then go to 40.
If N is less than one or N is greater than four, then fall through to 10.