Next: , Previous: , Up: Statements   [Contents][Index]


7.3 CASE Statement

The case statement selects one of a set of statements for execution, depending on a set of conditions.

CASE
  expr1 : statement1
[ expr2 : statement2
  … ]
[ ELSE statement ]
ENDCASE

The condition expressions expr1, expr2, and so on are evaluated in turn until the first non-zero value (i.e., true condition) is found. Then, the corresponding statement statement1 or statement2, etcetera, is executed. If none of the conditions evaluates to a non-zero value, then the else statement statement is executed, if an else part was specified. Otherwise, this case statement does nothing and control passes directly to the next statement.

All evaluated conditions must have scalar values.