Select case statement – Campbell Scientific CR9000X Measurement and Control System User Manual
Page 347

Section 9. Program Control Instructions
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] ]
[
CaseIs
expressionlist2
[statementblock-n] ]
[
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 Is
Keyword used before a comparison operator (=, <>, <, <=, >, or >=). If
the Is keyword is not used (ie: Case < 10), the program will not
compile. If Case Is Expression List is used (ie: Case Is 15), the
comparitor is assumed to be the equal sign (equivalent to Case Is = 15).
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.
9-17