5.3.6.6
Select Case
If depending on the value of an expression various commands should be executed then a Select
Case instruction seems to be an elegant solution:
Select Case Expression
Case
Instructions_1
Case
Instructions_2
.
.
Case constant_comparison_x
Instructions_x
Else
Instructions
End Case
For constant comparisons special comparisons and ranges can be defined . Here examples for all
possibilities:
The new features to use comparisons are introduced for Select Case statements with version
1.71. This extension is not available for CompactC switch statements.
The value of the Expression is calculated. Then the program execution will jump to the first constant
comparison that can be evaluated as true and will continue the program from there. If no constant
comparison can be fulfilled the Select Case construct will be left.
If an Else is defined within a Select Case instruction then the instructions after Else will be
executed if no constant comparison could be fulfilled.
Example:
Select Case
Case
b=b*2
Case =
b=b+2
© 2008 Conrad Electronic
constant_comparison1
constant_comparison2
' Else is optional
Comparison
Constant,
=
Constant
<
Constant
<=
Constant
>
Constant
>=
Constant
<>
Constant
Constant1
To
Constant2
a+2
1
5*5
Compiler
Execute on
Expression
equal
Constant
Expression
smaller
Constant
Expression
smaller equal
Expression
greater
Constant
Expression
greater equal
Expression
unequal
Constant
Constant1
<=
Expression
120
Constant
Constant
<=
Constant2
Need help?
Do you have a question about the C-Control Pro Mega Series and is the answer not in the manual?
Questions and answers