PreviousNextIndex

CASE statement

Provides a multi-branch decision based on the value of a single expression.

Syntax

CASE expression : 
  {  WHEN value [ OR WHEN value ] ... THEN 
       { block | statement } 
  } ... 
  [  OTHERWISE 
       { block | statement } 
  ] 
END [ CASE ] 

expression
WHEN value [ OR WHEN value ] . . . THEN
OTHERWISE
block
statement
END [ CASE ]
Example

The following fragment shows a simple example of a CASE statement:

r-case.p
DEFINE VARIABLE pay-stat AS INTEGER NO-UNDO INITIAL 1. 
UPDATE pay-stat VIEW-AS RADIO-SET 
  RADIO-ITEM unpaid   1 LABEL "Unpaid" 
  RADIO-ITEM part     2 LABEL "Partially paid" 
  RADIO-ITEM paid     3 LABEL "Paid in full". 
CASE pay-stat: 
  WHEN 1 THEN 
    MESSAGE "This account is unpaid.". 
  WHEN 2 THEN   
    MESSAGE "This account is partially paid.". 
  WHEN 3 THEN   
    MESSAGE "This account is paid in full.". 
END CASE. 

Notes

OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex