HP 3000 Manuals

GOTO Statement (Executable) [ HP FORTRAN 77/iX Reference ] MPE/iX 5.0 Documentation


HP FORTRAN 77/iX Reference

GOTO Statement (Executable) 

The GOTO statement transfers control to a labeled statement in the same
program unit.  It has three forms, which are described separately below:

   *   Unconditional GOTO
   *   Computed GOTO
   *   Assigned GOTO

Unconditional GOTO Statement (Executable) 

The unconditional GOTO statement transfers control to the specified
statement.

[]
----------------------------------------------------------------------------------------------- | | | | | Item | Description/Default | Restrictions | | | | | ----------------------------------------------------------------------------------------------- | | | | | label | Label of an executable statement. | None. | | | | | ----------------------------------------------------------------------------------------------- Computed GOTO Statement (Executable) The computed GOTO statement transfers control to one of several statements, depending on the value of an expression.
[]
----------------------------------------------------------------------------------------------- | | | | | Item | Description/Default | Restrictions | | | | | ----------------------------------------------------------------------------------------------- | | | | | label | Label of an executable statement. | None. | | | | | ----------------------------------------------------------------------------------------------- | | | | | expression | Arithmetic expression. | Any integer or real type. | | | | | ----------------------------------------------------------------------------------------------- The use of noninteger expressions is an extension to the ANSI 77 standard. The computed GOTO statement passes control to one of several labeled statements depending on the result of an evaluation. The expression is evaluated and truncated to an integer value (the index). The index selects the statement label in the label list. For example, if the index is 1, control passes to the statement whose label appears in the first position in the list of labels. If the index value is 2, the second label in the list is used, and so on. If the value of the expression is less than 1 or greater than the number of labels in the label list, control passes to the statement following the computed GOTO. Assigned GOTO Statement (Executable) The assigned GOTO statement transfers control to the statement whose label is stored in the variable by an ASSIGN statement.
[]
----------------------------------------------------------------------------------------------- | | | | | Item | Description/Default | Restrictions | | | | | ----------------------------------------------------------------------------------------------- | | | | | label | Label of an executable statement. | None. | | | | | ----------------------------------------------------------------------------------------------- | | | | | variable | Integer simple variable. | Must be INTEGER*4. | | | | | ----------------------------------------------------------------------------------------------- The variable must be given a label value of an executable statement through an ASSIGN statement prior to execution of the GOTO statement. When the assigned GOTO statement is executed, control transfers to the statement whose label matches the label value of variable. The optional labels following variable form a list of label values that variable might assume. If you use the list of labels, the compiler can sometimes produce more efficient object code. However, if the label list is specified and the value in variable is not in the list, the results are not defined. A run-time range error can result if the RANGE compiler directive is ON. Examples Notes -------------------------------------------------------------------------------------- GOTO 20 In this unconditional GOTO statement, control passes to the statement labeled 20 when the GOTO statement is executed. Statement 20 can be before or after the GOTO statement, but must be present in the same program unit. a = 3 In this computed GOTO statement, because a has a GOTO (30,60,50,100) a value of 3, control passes to statement 50. b = 1.5 In this computed GOTO statement, because INT(b + z) z = 1 = 2, control passes to statement 20. GOTO (10,20,40,40) b + z ASSIGN 10 TO age In this assigned GOTO statement, control transfers GOTO age to statement 10 when the GOTO statement is executed. ASSIGN 100 TO time In this assigned GOTO statement, control transfers GOTO time (90,100,150) to statement 100 when the GOTO statement is executed.


MPE/iX 5.0 Documentation