| United States-English |
|
|
|
![]() |
HP Fortran Compiler for HP-UX: HP Fortran Programmer's Reference > Chapter 10 HP
Fortran statementsCASE |
|
Marks start of statement block in a CASE construct. Syntax
DescriptionThe CASE statement is used in a CASE construct to mark the start of a statement block. The CASE construct can consist of multiple blocks; at most, one is selected for execution. Selection is determined by comparing the case index produced by the SELECT CASE statement to the case-selector in each CASE statement. If a match is found, the statement block under the matching case-selector executes. A match between the case index (c) and case-selector is determined for each form of case-selector, as follows:
If CASE DEFAULT is not present and no match is found with any of the other CASE statements, none of the statement blocks within the CASE construct executes and execution resumes with the first executable statement following the END SELECT statement. At most only one DEFAULT selector can appear within a CASE construct. Each CASE statement must specify a unique value or range of values within a particular CASE construct. Only one match can occur, and only one statement block can execute. All case-selectors and the case index within a particular CASE construct must be of the same type: integer, character, or logical. However, the lengths of character types can differ. The colon forms—low:, :high, or low:high—are not permitted for a logical type. Although putting the CASE statements in order according to range may improve readability, it is not necessary for correct or optimal execution of the CASE construct. In particular, DEFAULT can appear anywhere among the CASE statements and need not be the last. CASE statements inside a named CASE construct need not specify construct-name; but if they do, the name they specify must match that of the SELECT CASE. A CASE statement can have an empty statement block. ExamplesThe following example considers a person’s credits and debits and prints a message indicating whether a resulting account balance will be overdrawn, empty, uncomfortably small, or sufficient:
Related statementsSELECT CASE and END (construct) Related conceptsThe CASE construct is described in “CASE construct”. |
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||