
Section 9. Program Control Instructions
Part Description
SelectCase Begins the SelectCase decision control structure. Must
appear before any other part of the SelectCase 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
EndSelect. Control then passes to the statement following
EndSelect. 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.
CaseElse 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 CaseElse statement and no expression listed in
the Case clauses matches testexpression, program execution
continues at the statement following EndSelect.
EndSelect Ends the Select Case. Must appear after all other statements
in the Select Case control structure.
The argument expressionlist has these parts:
Part Description
expression Any numeric expression.
To Keyword used to specify a range of values. If you use the
To keyword to indicate a range of values, the smaller value
must precede To.
Although not required, it is a good idea to have a CaseElse statement in your
SelectCase block to handle unforeseen testexpression values.
You can use multiple expressions or ranges in each Case clause. For example,
the following line is valid:
Case 1 To 4, 7 To 9, 11, 13
SelectCase statements can be nested. Each SelectCase statement must have a
matching EndSelect statement.
9-14
Kommentare zu diesen Handbüchern