Use the CASE statement to specify that a group of statements is to be executed, if the evaluated value of the selector (entered after CASE ) corresponds to a label which is entered for this group of statements. If the value of the selector does not correspond to any of the labels, then either no statement is to be executed, or the statement group following the ELSE keyword is to be executed,
A label may be one or more integer →literals/→variables, enumerated values or subranges and must be evaluated as →constant value during the runtime. The data type of the labels must be implicitly convertible into the data type of the selector.
Detailed explanation about CASE
Part of CASE statement
|
Explanation
|
CASE selector OF
1: statements-A;
2, 3: statements-B;
4..6, 7: statements-C;
...
|
|
-
If the value of the selector corresponds to label 1 (hence: in case of value = 1 ), the execution continues with the statement block statements-A . After processing the last statement, the execution continues after END_CASE .
-
In case of value = 2 or 3 , the execution continues with the statement block statements-B . After processing the last statement, the execution continues after END_CASE .
-
In case of value = 4 , 5 , 6 or 7 , the execution continues with the statement block statements-C . After processing the last statement, the execution continues after END_CASE .
Each statement block may contain as many statements as you like. You may insert as many labels and statement blocks as you like. If you enter the same value for labels, the statement block first entered is selected for execution because Neuron Power Engineer compares from top to bottom.
|
|
The statement block behind ELSE is only processed, if none of the labels matches the value of the selector. The statement block may contain as many statements as you like. After processing the last statement, the execution continues after END_CASE .
You may skip the ELSE -part.
|
|
This concludes the CASE -statement.
|
|