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

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
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,
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.
Simple IF Statement
The most common form of the
condition is true. This is written as an
code. For example:
This example tests if
condition was true, I/O pin P1 is toggled next.
Since the
and is executed only if the
the
another version of the same example:
This example is very similar to the first, except there are now two lines of code indented from
the
finally the
!outa[1]
the
Combining Conditions
The Condition(s) field is evaluated as one single Boolean condition, but it can be made up of
more than one Boolean expression by combining them with the
pages 272-273. For example:
if X > 10
!outa[1]
if X > 10
waitcnt(2_000 + cnt)
waitcnt
IF
IF
!outa[0]
!outa[0]
!outa[1]
statement. In this case, if
line, so it is executed next whether or not the
lines are skipped (since they are indented and part of the IfStatement(s) block) and
!outa[0]
waitcnt
line is executed (since it is not indented; it is not part of the IfStatement(s) block).
line is executed. If, however,
line is indented from the
X
is greater than 10; if it is, I/O pin 0 is toggled. Whether or not the
IF
condition is true. The next line,
IF
X
conditional command performs an action if, and only if, a
is greater than 10, P0 is toggled then P1 is toggled and
IF
'If X is greater than 10
'Toggle P0
'Toggle P1
'If X is greater than 10
'Toggle P0
'Toggle P1
'Wait for 2,000 cycles
statement followed by one or more indented lines of
IF
4: Spin Language Reference –
X
line, it belongs to the IfStatement(s) block
was not greater than 10, the
IF
’s Condition(s) was true. Here’s
Propeller Manual v1.0 · Page 221
!outa[1]
AND
and
, is not indented from
OR
operators; see
!outa[0]
and
IF

Related parts for 122-32000