CASE
Syntax
![]()
Command
Mandatory parameter Optional parameter Mandatory keyword Optional keyword |
STARTCASE <Item>
CASE <Value list>
<Code lines>
[CASE <Value list>
<Code lines>
[CASE <Value list>
<Code lines>
...
...]]
[ELSE
<Code lines>]
ENDCASE
Description
Executes or skips implemented <Code lines>, depending on whether or not the specified <Item> matches with
a value in a specific <Value list>.
If the <Item> is not found in a <Value list>, then the further code is skipped until the next CASE...,
ELSE or ENDCASE is encountered. If the <Item> is found in a <Value list>, then the code directly below
the concerned CASE condition is executed until the next CASE.., ELSE or ENDCASE is encountered. The next CASE and
ELSE will then behave like an ENDCASE, which always ends the instruction. It is not allowed to include an
<Item> in multiple value lists, in that case a Duplicate case label error is given while validating.
If a system enumeration is used in CASE, all other CASE values must also be enums of the same type. STARTCASE must be used in conjunction, using a system enumeration compatible dynamic property. Also see pages STARTCASE and System Enums.
Diagram
Returned value type
None
Parameters
Parameter | Description |
<Item> | Expression of which the result is compared against the values in the value lists. |
<Value list> | Specification of values that are separated by a space. The
|
<Code lines> |
Case dependant code that may or may not be executed. If a case condition is met, the applicable code will be executed. If no conditions are met the code following ELSE is executed. |
Remarks
STARTCASE may be abbreviated to SC, ENDCASE to EC and CASE to CS
Examples
case 'inq' 'search'
inq := true
xmaint := 'INQ'
case 'chg'
chg := true
xmaint := 'CHG'
case 'del'
del := true
xmaint := 'DEL'
case 'add'
add := true
xmaint := 'ADD'
else
smex('Unknown action!')
endcase
cs 1
gotoform('startform')
cs 2 3 4
gotoform('otherform')
cs 5..8
gotoform('lastform')
ec
cs lb-address
sme('address found')
cs lb-phone
sme('phone found')
ec
case SE-TEXTALIGNMENT.LEFTJUSTIFY
sme ('left')
case SE-TEXTALIGNMENT.CENTERJUSTIFY
sme ('center')
case SE-TEXTALIGNMENT.RIGHTJUSTIFY
sme ('right')
endcase