Purpose
The computed GO TO statement transfers program control to one of possibly several executable statements.
Format
>>-GO TO--(--stmt_label_list--)--+---+--arith_expr------------->< '-,-' |
is a scalar integer expression.
+-------------------------------IBM Extension--------------------------------+
It can also be real or complex. If the value of the expression is noninteger, XL Fortran converts it to INTEGER(4) before using it.
+----------------------------End of IBM Extension----------------------------+
When a computed GO TO statement is executed, the arith_expr is evaluated. The resulting value is used as an index into stmt_label_list. Control then transfers to the statement whose statement label you identify by the index. For example, if the value of arith_expr is 4, control transfers to the statement whose statement label is fourth in the stmt_label_list, provided there are at least four labels in the list.
If the value of arith_expr is less than 1 or greater than the number of statement labels in the list, the GO TO statement has no effect (like a CONTINUE statement), and the next statement is executed.
INTEGER NEXT
·
·
·
GO TO (100,200) NEXT 10 PRINT *,'Control transfers here if NEXT does not equal 1 or 2'
·
·
·
100 PRINT *,'Control transfers here if NEXT = 1'
·
·
·
200 PRINT *,'Control transfers here if NEXT = 2'
Related Information