HP Fortran Programmer's Reference (September 2007)

HP Fortran statements
GO TO (computed)
Chapter 10366
GO TO (computed)
Transfers control to one of several labels.
Syntax
GO TO (
label-list
) [,]
arithmetic-expression
label-list
is a list of statement labels, separated by commas.
arithmetic-expression
is a scalar integer expression. As an extension, HP Fortran also allows the
expression to be of type real or double precision.
Description
The computed GO TO statement transfers control to one of several labeled statements,
depending on the value of
arithmetic-expression
. After
arithmetic-expression
is
evaluated (and, if necessary, truncated to an integer value), control transfers to the statement
label whose position in
label-list
corresponds to the truncated value of
arithmetic-expression
.
If the value of
arithmetic-expression
is less than 1 or greater than the total number of
labels in
label-list
, control transfers to the executable statement immediately following the
computed GO TO statement.
Examples
index = 3
! Branch made to the statement labeled 30.
GO TO (10, 20, 30, 40) index
Related statements
SELECT CASE, GO TO (assigned), and GO TO (unconditional)
Related concepts
For information about flow control statements, see “Flow control statements” on page 146.