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

Create successful ePaper yourself

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

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

2.42 EXIT Statement<br />

EXIT<br />

[: block-label]<br />

The EXIT statement is used to transfer control:<br />

1. from within a loop (DO, DO WHILE, WHILE or LOOP) to the statement following the loop,<br />

2. from within a GUESS or ADMIT block to the statement following the ENDGUESS statement, or<br />

3. from within a remote block to the statement following the EXECUTE statement that invoked the<br />

remote block.<br />

The EXIT statement may be used to cause a transfer of control to the first executable statement that follows<br />

the terminal statement of the block which contains it. Examples of such terminal statements are END DO,<br />

END LOOP, END WHILE, UNTIL, etc. If block-label is present then control is transferred out of<br />

the block identified by that block label. The EXIT statement is an extension to the <strong>FORTRAN</strong> <strong>77</strong><br />

language.<br />

Example:<br />

LOOP<br />

WRITE( UNIT=*, FMT=’(A)’ ) ’Enter a number’<br />

READ( UNIT=*, FMT=’(F10.4)’, IOSTAT=IOS ) X<br />

IF( IOS .NE. 0 ) EXIT<br />

IF( X .LT. 0 ) EXIT<br />

PRINT *, X, SQRT( X )<br />

END LOOP<br />

END<br />

For more information, see the chapter entitled "Program Structure Control Statements" on page 193.<br />

74 EXIT Statement

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

Saved successfully!

Ooh no, something went wrong!