02.07.2013 Views

HP Fortran Programmer's Reference

HP Fortran Programmer's Reference

HP Fortran Programmer's Reference

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Execution control<br />

Flow control statements<br />

Execution logic<br />

Control transfers to the executable statement at integer-variable.<br />

Example<br />

INTEGER int_label<br />

.<br />

.<br />

.<br />

ASSIGN 20 TO int_label<br />

.<br />

.<br />

.<br />

GOTO int_label<br />

.<br />

.<br />

.<br />

20 ...<br />

Computed GO TO statement<br />

The computed GO TO statement transfers control to one of several labeled statements, as<br />

determined by the value of an arithmetic expression.<br />

Syntax<br />

GO TO ( label-list ) [ , ] integer-expression<br />

Execution logic<br />

1. integer-expression is evaluated.<br />

2. The resulting integer value (the index) specifies the ordinal position of the label that is<br />

selected from label-list.<br />

3. Control transfers to the executable statement with the selected label. If the value of the<br />

index is less than 1 or greater than the number of labels in label-list, the computed GO<br />

TO statement has no effect, and control passes to the next executable statement in the<br />

program.<br />

Example<br />

116<br />

DO<br />

PRINT *, ”Enter a number 1-3: ”<br />

READ *, k<br />

GO TO (20, 30, 40) k<br />

PRINT *, ”Number out of range.”<br />

Chapter 6

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!