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>FORTRAN</strong> Statements<br />

2.10 CASE Statement<br />

CASE cl<br />

where:<br />

cl<br />

is a list, enclosed in parentheses, of one or more cases separated by commas, or the DEFAULT<br />

keyword. A case is either<br />

(a)<br />

(b)<br />

a single integer, logical or character constant expression or<br />

an integer, logical or character constant expression followed by a colon followed by<br />

another expression or the same type. This form of a case defines a range of values<br />

consisting of all integers or characters greater than or equal to the value of the<br />

expression preceding the colon and less than or equal to the value of the expression<br />

following the colon.<br />

The CASE statement is used in conjunction with the SELECT statement. The CASE statement marks the<br />

start of a new CASE block which is a series of zero or more statements ending in another CASE statement, a<br />

CASE DEFAULT statement, or an END SELECT statement.<br />

A particular case value or range of values must not be contained in more than one CASE block.<br />

The CASE DEFAULT statement is used to indicate a block of statements that are to be executed when no<br />

other case is selected.<br />

Example:<br />

SELECT CASE ( CH )<br />

CASE ( ’a’ : ’z’ )<br />

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

CASE ( ’A’ : ’Z’ )<br />

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

CASE ( ’0’ : ’9’ )<br />

PRINT *, ’Digit’<br />

CASE DEFAULT<br />

PRINT *, ’Special character’<br />

END SELECT<br />

In order to retain compatibility with earlier versions of WATCOM <strong>FORTRAN</strong> <strong>77</strong> compilers, the<br />

OTHERWISE statement may be used in place of the CASE DEFAULT statement.<br />

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

CASE Statement 25

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

Saved successfully!

Ooh no, something went wrong!