Old Operator Symbol ------------ ------ .LT. <.GT.> .EQ. == .LE. <= .GE.>= .NE. /=
name: IF (logical argument) THEN statements ELSE IF (logical argument) THEN name statements . . . END IF name
SELECT CASE (selector) CASE (list #1) statements CASE (list #2) statements . . . CASE DEFAULT statements END SELECT
The selector may be an integer, character, or logical expression. Just like IF_ELSE blocks, CASE constructs may also be named. The list #i is a list of one or more possible values of the selector index. The DEFAULT option in a CASE construct may be omitted, but it is recognized as good programming style to always include it.
Consider the following example of the use of the CASE construct:
SELECT CASE (Freq_Fly_Points) CASE (:19999) WRITE(*,*) 'Keep flying - no free ticket yet!' CASE(20000:49999) WRITE(*,*) 'Woo-Hoo!! Free ticket in continental U.S.!' CASE(50000:) WRITE(*,*) 'Hawaii here I come!!' CASE DEFAULT WRITE(*,*) 'Sorry - you aren't going anywhere :( ' END SELECT
Here we use the CASE construct to evaluate what sort of reward we might be entitled to on our favorite airline based on the number of accrued frequent flyer points. If we have less than 20,000 points, we don't get any reward... yet. If we have between 20,000 and 49,000 points, we can get a free ticket in the continental U.S.. If we have more than 50,000 points, we are on our way to Hawaii!! In this case, the DEFAULT option should never execute, but it is there just in case!
Copyright © 1996-7 by Stanford University. All rights reserved.