EasyManua.ls Logo

Parallax BASIC Stamp 2e - Page 151

Default Icon
353 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
5: BASIC Stamp Command Reference IF…THEN
BASIC Stamp Programming Manual 2.0c www.parallaxinc.com Page 149
IF…THEN
BS1 BS2 BS2e BS2sx BS2p
IF Condition THEN Address
Function
Evaluate Condition and, if it is true, go to the point in the program marked
by Address.
Condition is a statement, such as “x = 7” that can be evaluated as
true or false. The Condition can be a very simple or very complex
relationship, as described below.
Address is a label that specifies where to go in the event that
Condition is true.
Quick Facts
BS1 BS2, BS2e, BS2sx and BS2p
Comparison
operators
=, <>, >, <, >=, <= =, <>, >, <, >=, <=
Conditional
logic operators
AND, OR NOT, AND, OR, XOR
Format of
condition
Variable Comparison Value
;where Value is a variable
or constant
Value1 Comparison Value2
;where Value1 and Value2 can by
any of variable, constant or
expression
Parentheses
Not Allowed Allowed
Explanation
IF...THEN is PBASIC’s decision maker. It tests a condition and, if that
condition is true, goes to a point in the program specified by an address
label. The condition that IF...THEN tests is written as a mixture of
comparison and logic operators. The available comparison operators are:
Comparison Operator
Symbol
Definition
= Equal
<> Not Equal
> Greater Than
< Less Than
>= Greater Than or Equal To
<= Less Than or Equal To
Comparisons are always written in the form: Value1 Comparison Value2.
The values to be compared can be any combination of variables (any size),
1
2
e
2
sx
2
p
2
Table 5.23: IF…THEN Comparison
Operators.
NOTE: On the BS1, expressions
are not allowed as arguments.
Also, the Value1 (to the left of
comparison) must be a variable.
NOTE: Expressions are not allowed
as arguments on the BS1. The
rangeofthe Pin argumentonthe
Table
5.22: IF…THEN Quick Facts.

Table of Contents

Related product manuals