Select case statement – Campbell Scientific CR5000 Measurement and Control Module User Manual
Page 221

Section 9. Program Control Instructions
9-15
Select Case Statement
Executes one of several statement blocks depending on the value of an
expression.
Syntax
Select Case testexpression
[Case expressionlist1
[statementblock-1] ]
[Case expressionlist2
[statementblock-2] ]
[Case Else
[statementblock-n] ]
End Select
The Select Case syntax has these parts:
Part
Description
Select Case
Begins the Select Case decision control structure. Must
appear before any other part of the Select Case structure.
testexpression
Any numeric or string expression. If testexpression matches
the expressionlist associated with a Case clause, the
statementblock following that Case clause is executed up to
the next Case clause, or for the final one, up to the End
Select. Control then passes to the statement following End
Select. If testexpression matches more than one Case
clause, only the statements following the first match are
executed.
Case
Sets apart a group of CRBasic statements to be executed if
an expression in expressionlist matches testexpression.
expressionlist
The expressionlist consists of a comma-delimited list of one
or more of the following forms.
expression
expression To expression
Is compare-operator expression
statementblock
Elements statementblock-1 to statementblock-n consist of
any number of CRBasic statements on one or more lines.
Case Else
Keyword indicating the statementblock to be executed if no
match is found between the testexpression and an
expressionlist in any of the other Case selections. When
there is no Case Else statement and no expression listed in
the Case clauses matches testexpression, program execution
continues at the statement following End Select.
End Select
Ends the Select Case. Must appear after all other statements
in the Select Case control structure.