BASIC stamp manual v2.2
5: BASIC Stamp Command Reference – IF...THEN
BASIC Stamp Syntax and Reference Manual 2.2 • www.parallax.com • Page 235
The condition “value1 = 5 AND value2 = 10” is not true. Although value1
is 5, value2 is not 10. The AND operator works just as it does in English;
both conditions must be true for the statement to be true. The OR operator
also works in a familiar way; if one or the other or both conditions are
true, then the statement is true. The XOR operator (short for exclusive-
OR) may not be familiar, but it does have an English counterpart: If one
condition or the other (but not both) is true, then the statement is true.
Table 5.40 below summarizes the effects of the conditional logic operators.
On all BS2 models you can alter the order in which comparisons and
logical operations are performed by using parentheses. Operations are
normally evaluated left-to-right. Putting parentheses around an operation
forces PBASIC 2.0 and PBASIC 2.5 to evaluate it before operations that are
not in parentheses.
Table 5.40: Conditional Logic
Operators Truth Tables.
NOTE: The NOT and XOR operators
are not available on the BS1.
Truth Table for Logical Operator: NOT
Condition A NOT A
False True
True False
Truth Table for Logical Operator: AND
Condition A Condition B A AND B
False False False
False True False
True False False
True True True
Truth Table for Logical Operator: OR
Condition A Condition B A OR B
False False False
False True True
True False True
True True True
Truth Table for Logical Operator: XOR
Condition A Condition B A XOR B
False False False
False True True
True False True
True True False
1
NOTE: On the BS1, parentheses are
not allowed within arguments.
1