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.

Program Structure Control Statements<br />

(iv) I = 3:<br />

- Y will be assigned the value of the expression Y * 13. + X<br />

- 0.213 will be subtracted from X<br />

- control will pass to the statement after the END SELECT statement<br />

(v) I = 4:<br />

- Z, Y and X will be assigned new values<br />

- the string CASE 4, followed by the values of X, Y and Z will be printed<br />

- control will pass to the statement after the END SELECT statement<br />

(vi) I = 5, 6, ...:<br />

- control will pass to the statement after the END SELECT statement<br />

CASE DEFAULT allows a block of code to be specified for execution when the SELECT expression is out<br />

of range. It must follow all CASE-blocks and thus is ended by the END SELECT statement. The CASE<br />

DEFAULT statement terminates the previous and last CASE-block. Note that only one CASE DEFAULT<br />

block may be specified in a SELECT construct.<br />

If a CASE DEFAULT block were included in the above example, it would be executed in cases (i) and (vi)<br />

of the description. After a CASE DEFAULT block is executed, control then passes to the statement after<br />

the END SELECT statement.<br />

Empty or null case blocks are permitted (that is, two CASE statements with no statements between). The<br />

net result of executing a null CASE-block is to effectively bypass the SELECT construct.<br />

Example:<br />

SELECT CASE ( I * 4 - J )<br />

CASE (-10 : -5)<br />

PRINT *,’First case:’<br />

PRINT *,’-10

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

Saved successfully!

Ooh no, something went wrong!