The case command functions like an if-then-else statement with multiple ifs. It tells DataEase to compare an expression to a series of values and execute a different action (or group of actions) based on which comparison is true.
When processing reaches a case command, DataEase compares the expression that follows the case command to each of the statements specified by the keyword value.
If the first comparison is true, DataEase executes all the actions between that value statement and the next value statement.
If the first comparison is not true, the case expression is compared to the next value statement. This comparing of values continues in top-to-bottom sequence from one value statement to the next until a true comparison is made.
If none of the specified value comparisons are true, DataEase executes the actions specified after the keyword others. If the others keyword is not present, DataEase executes none of the specified actions. It continues processing the remainder of the script.
As soon as the actions following any single statement are executed, processing passes to the first action following the end command for the case structure.
case ( EXPRESSION)
value COMPARISON 1 :
ACTION SERIES 1 .
[value COMPARISON 2 :
ACTION SERIES 2 .]
[value COMPARISON 3 :
ACTION SERIES 3 .]
DEFAULT ACTION SERIES .]
The case command requires a case expression, at least one value statement, and an end command. Subsequent value statements, actions, and the others keyword are optional. If others is used, it must follow the last value statement.
The case expression must be enclosed in parentheses. It can be a field, a variable, or any other expression except a boolean expression (true or false). Each comparison value can be a constant, a variable, an expression, or a range of values.
An action can specify any valid procedure command including another if, while, or case command. Each nested command must be completed before processing passes to the first action after the end command (see the nested actions entry in this Lexicon).
When case commands are nested, the first end corresponds to the last preceding case, and each case command must be matched with a corresponding end command. This rule applies to all nested Procedural commands (including case, for, if, and while).
When you select case from the command pick list, DataEase automatically enters the opening ( (parenthesis).
value "FRANK" :
call menu "MAIN MENU" .
value "TOM" :
call menu "CLUB ADMINISTRATION" .
value "CAROL" :
run procedure "MAINTENANCE" .
record entry "MEMBERS" .
This script tells DataEase: (1) If the current user is Frank, display the MAIN MENU document, (2) if the current user is Tom, display the CLUB ADMINISTRATION menu document, (3) if the current user is Carol, run the MAINTENANCE procedure, and (4) if the current user is anyone other than Frank, Tom, or Carol, display the MEMBERS form.