BASIC stamp manual v2.2

IF…THEN – BASIC Stamp Command Reference
Page 234 BASIC Stamp Syntax and Reference Manual 2.2 www.parallax.com
Test:
IF -99 < 100 THEN Is_Less
DEBUG "Greater than or equal to 100"
END
Is_Less:
DEBUG "Less than 100"
END
Although –99 is obviously less than 100, the program will say it is greater.
The problem is that –99 is internally represented as the two’s complement
value 65437, which (using unsigned math) is greater than 100. This
phenomena will occur whether or not the negative value is a constant,
variable or expression.
IF...THEN supports the conditional logic operators NOT, AND, OR, and
XOR to allow for more sophisticated conditions, such as multi-part
conditions. See Table 5.38 for a list of the operators and Table 5.40 for
their effects.
The NOT operator inverts the outcome of a condition, changing false to
true, and true to false. The following IF...THENs are equivalent:
IF x <> 100 THEN Not_Equal
IF NOT x = 100 THEN Not_Equal
The operators AND, OR, and XOR can be used to join the results of two
conditions to produce a single true/false result. AND and OR work the
same as they do in everyday speech. Run the example below once with
AND (as shown) and again, substituting OR for AND:
value1 VAR Byte
value2 VAR Byte
Setup:
value1 = 5
value2 = 9
Main:
IF value1 = 5 AND value2 = 10 THEN Is_True
DEBUG "Statement is False"
END
Is_True:
DEBUG "Statement is True"
END
NOTE: For BS1's, change lines1 and 2
to:
SYMBOL value1 = B2
SYMBOL value2 = B3
L
OGICAL OPERATORS (NOT, AND, OR
AND
XOR).
NOTE: The NOT and XOR operators
are not available on the BS1.
1