27220 Parallax Inc, 27220 Datasheet - Page 23

BOOK STAMPWORKS

27220

Manufacturer Part Number
27220
Description
BOOK STAMPWORKS
Manufacturer
Parallax Inc
Datasheet

Specifications of 27220

Accessory Type
Booklet
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
StampWorks
Lead Free Status / RoHS Status
Lead free / RoHS Compliant, Not applicable / Not applicable
Note that the code statements are nested in an IF-THEN-ENDIF structure which
does not require a branch label. If the condition evaluates as False, the program will
continue at the line that follows ENDIF. Another use of this conditional structure is
to add the ELSE clause:
If the condition evaluates as True then statements 1 – 3 will run, otherwise
statements 4 – 6 will run.
As your requirements become more sophisticated, you’ll find that you’ll want your
program to branch to any number of locations based on the value of a control
variable. One approach is to use multiple IF-THEN constructs.
This approach is valid and does get used. Thankfully, PBASIC has a special command
called BRANCH that allows a program to jump to any number of addresses based on
the value of an index variable. BRANCH is a little more complicated in its setup, but
very powerful in that it can replace multiple IF-THEN statements. BRANCH requires
a control (index) variable and a list of addresses
The previous listing can be replaced with one line of code:
Start:
Start:
IF (condition) THEN
ENDIF
IF (condition) THEN
ELSE
ENDIF
IF (index = 0) THEN Label_0
IF (index = 1) THEN Label_1
IF (index = 2) THEN Label_2
BRANCH index, [Label_0, Label_1, Label_2]
statement 1
statement 2
statement 3
statement 1
statement 2
statement 3
statement 4
statement 5
statement 6

Related parts for 27220