24.11.2014 Views

Open Watcom FORTRAN 77 Language Reference

Open Watcom FORTRAN 77 Language Reference

Open Watcom FORTRAN 77 Language Reference

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Language</strong> <strong>Reference</strong><br />

9.13 QUIT<br />

QUIT<br />

[ : block-label]<br />

The QUIT statement may be used to transfer control to the first executable statement following the terminal<br />

statement of the block in which it is contained.<br />

When transferring out of a loop, control is passed to the statement following the END DO, END WHILE,<br />

END LOOP or UNTIL statement.<br />

When transferring out of a GUESS block, control is passed to the statement after the next ADMIT or END<br />

GUESS statement.<br />

When transferring out of an IF-block or SELECT-block, control is passed to the statement after the<br />

corresponding END IF or END SELECT statement.<br />

When transferring out of a REMOTE-block, control passes to the statement following the EXECUTE<br />

statement that invoked the REMOTE-block.<br />

If no block label is specified in the QUIT statement, control is transferred from the immediately enclosing<br />

structure. If several structures or DO-loops are nested, it is possible to exit from any one of them by<br />

specifying the block label of the corresponding block structure.<br />

The QUIT statement is most commonly used as the statement in a logical IF or AT END statement but<br />

may also be used to cause an unconditional transfer of control. (The AT END statement is described in a<br />

subsequent section).<br />

Examples of the QUIT statement with and without a block label follow.<br />

Example:<br />

CHARACTER CH<br />

READ *, CH<br />

GUESS<br />

IF( CH .LT. ’a’ )QUIT<br />

IF( CH .GT. ’z’ )QUIT<br />

PRINT *, ’Lower case letter’<br />

ADMIT<br />

IF( CH .LT. ’A’ )QUIT<br />

IF( CH .GT. ’Z’ )QUIT<br />

PRINT *, ’Upper case letter’<br />

ADMIT<br />

IF( CH .LT. ’0’ )QUIT<br />

IF( CH .GT. ’9’ )QUIT<br />

PRINT *, ’Digit’<br />

ADMIT<br />

PRINT *, ’Special character’<br />

END GUESS<br />

END<br />

The above statements read and print values until an end of file occurs. At that point control is passed to the<br />

QUIT statement, as specified by the AT END statement. The QUIT statement causes control to continue<br />

with the statement after the END LOOP statement.<br />

208 QUIT

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

Saved successfully!

Ooh no, something went wrong!