CASE instruction
With the CASE instructions one can combine several conditioned instructions with the same condition variable in one construct.
Syntax:
CASE <Var1> OF
<Value 1>:
<instruction 1>
<Value 2>:
<instruction 2>
...
<Value n>:
<instruction n>
ELSE
<ELSE-instruction>
END_CASE;
A CASE instruction is processed according to the following model:
- If the variable in <Var1> has the value <Value i>, then the instruction <Instruction i> is executed.
- If <Var1> has none of the indicated values, then the <ELSE Instruction> is executed.
- If the same instruction is to be executed for several values of the variables, then one can write these values one after the other separated by commas, and thus condition the common execution.
Example:
CASE INT1 OF
1, 5:
BOOL1 := TRUE;
BOOL3 := FALSE;
2:
BOOL2 := FALSE;
BOOL3 := TRUE;
ELSE
BOOL1 := NOT BOOL1;
BOOL2 := BOOL1 OR BOOL2;
END_CASE;