BASIC stamp manual v2.2

5: BASIC Stamp Command Reference – SELECT...CASE
BASIC Stamp Syntax and Reference Manual 2.2 www.parallax.com Page 387
SELECT…CASE
BS1 BS2 BS2e BS2sx BS2p BS2pe BS2px
SELECT Expression
CASE Condition(s)
Statement(s)
{ CASE Condition(s)
Statement(s)... }
{ CASE ELSE
Statement(s) }
ENDSELECT
Function
Evaluate Expression and conditionally execute a code block based on
comparison to Condition(s) then continue execution with line following
ENDSELECT.
Expression is a variable, a constant, or an expression.
Condition is a statement that, when comapred to Expression, can be
evaluated as True or False. The Condition can be a very simple or
very complex relationship, as described below. Multiple conditions
within the same CASE can be separated by commas ( , ).
Statement is any valid PBASIC instruction.
Quick Facts
Table 5.92: SELECT...CASE
Quick Facts.
All BS2 Models
Comparison Operators
=, <>, >, <, >=, <=
Conditional
Logic Operators
Not allowed, however multiple conditions can be
separated by commas (,) which act like a logical OR
operator.
Format of Condition
Comparison Value
where Value can by any of variable, constant or
expression
Parentheses
Allowed to specify order of execution within
expressions.
Maximum Nested
SELECT Statements
16
Maximum CASEs per SELECT
16
Related Commands
IF...THEN, ON, and BRANCH
All
2
NOTE: SELECT...CASE requires
PBASIC 2.5.