Propeller Manual

Table Of Contents
2: Spin Language Reference – CASE
Propeller Manual v1.1 · Page 59
CASE
Command: Compare expression against matching expression(s) and execute code block if
match found.
((PUB PRI))
CASE CaseExpression
MatchExpression :
Statement(s)
MatchExpression :
Statement(s)
OTHER :
Statement(s)
CaseExpression is the expression to compare.
MatchExpression is a singular or comma-delimited set of value- and/or range-
expressions, to compare CaseExpression against. Each MatchExpression must be
followed by a colon (:).
Statement(s) is a block of one or more lines of code to execute when the
CaseExpression matches the associated MatchExpression. The first, or only,
statement in Statement(s) may appear to the right of the colon on the
MatchExpression line, or below it and slightly indented from the MatchExpression
itself.
Explanation
CASE is one of the three conditional commands (IF, IFNOT, and T CASE) that conditionally
executes a block of code.
CASE is the preferred structure to use, as opposed to
IF..ELSEIF..ELSE, when you need to compare the equality of CaseExpression to a number of
different values.
CASE compares CaseExpression against the values of each MatchExpression, in order, and if a
match is found, executes the associated Statement(s). If no previous matches were found, the
Statement(s) associated with the optional
OTHER command are executed.
Indention is Critical
IMPORTANT: Indention is critical. The Spin language relies on indention (of one space or
more) on lines following conditional commands to determine if they belong to that command
or not. To have the Propeller Tool indicate these logically grouped blocks of code on-screen,