122-32000 Parallax Inc, 122-32000 Datasheet - Page 172

MANUAL PROPELLER

122-32000

Manufacturer Part Number
122-32000
Description
MANUAL PROPELLER
Manufacturer
Parallax Inc
Datasheets

Specifications of 122-32000

Accessory Type
Manual
Lead Free Status / RoHS Status
Lead free / RoHS Compliant
For Use With/related Products
Propeller Education (PE) Kit
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
you can press Ctrl + I to turn on block-group indicators. Pressing Ctrl + I again will disable
that feature. See Indenting and Outdenting, page 69, and Block-Group Indicators, page 74.
Using CASE
CASE
expression. The following example assumes
Since the MatchExpression lines are indented from the
structure and are executed based on the CaseExpression comparison results. The next line,
X += 5
This example compares the value of
40
the range
the
Using OTHER
The optional
structure. For example:
This example is similar to the last one except that the third MatchStatement checks for the
range 20 to 30 and there’s an
in the range 20 to 30, the Statement(s) block following
X += 5
There is an important concept to note about this example. If
or if
MatchExpressions are checked, one at a time, in the order they are listed and only the first
Page 172 · Propeller Manual v1.0
. If
case X+Y
X += 5
case X+Y
X += 5
X += 5
X + Y
is handy where one of many actions needs to be performed depending on the value of an
10, 15: !outa[0]
A*2
30..40: !outa[2]
10, 15: !outa[0]
25
20..30: !outa[2]
OTHER : !outa[3]
X + Y
, is not indented from
line is executed.
– Spin Language Reference
30
is 25, P1 is toggled, or if
line is executed next.
equals 10 or 15, P0 is toggled. If
through
: !outa[1]
: !outa[1]
OTHER
component of
40
, inclusive, then P2 is toggled. Whether or not any match was found,
CASE
OTHER
, so it is executed regardless of the
CASE
component. If
X + Y
X + Y
'Test X+Y
'X+Y = 10 or 15? Toggle P0
'X+Y = A*2? Toggle P1
'X+Y in 30 to 40? Toggle P2
'Add 5 to X
'Test X+Y
'X+Y = 10 or 15? Toggle P0
'X+Y = 25? Toggle P1
'X+Y in 20 to 30? Toggle P2
'Othewise toggle P3
'Add 5 to X
is similar to the optional
is 20 to 30, P2 is toggled, etc. This is because the
against
A
,
X + Y
X
and
X + Y
10 or 15, A*2
Y
equals
OTHER
are variables defined earlier.
CASE
does not equal 10, 15, 25, or is not
A*2
X + Y
is executed. Following that, the
line, they belong to the
, P1 is toggled. If
ELSE
is 10 or 15, P0 is toggled,
and the range
CASE
component of an
results.
30
X + Y
through
CASE
is in
IF

Related parts for 122-32000