IF…THEN - BASIC Stamp Command Reference
Page 152
•
BASIC Stamp Programming Manual 2.0b
•
www.parallaxinc.com
counterpart: If one condition or the other (but not both) is true, then the
statement is true.
Table 5.24 below summarizes the effects of the conditional logic operators.
As with math, 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
PBASIC2 to evaluate it before operations not in parentheses.
Condition A
NOT A
False
True
True
False
Condition A
Condition B
A AND B
False
False
False
False
True
False
True
False
False
True
True
True
Condition A
Condition B
A OR B
False
False
True
False
True
True
True
False
True
True
True
False
Condition A
Condition B
A XOR B
False
False
False
False
True
True
True
False
True
True
True
False
Unlike the IF...THEN commands in other BASIC's, PBASIC’s IF...THEN
can only go to a label as the result of a decision. It cannot conditionally
perform some instruction, as in “IF x < 20 THEN y = y + 1.” To achieve
this in PBASIC, you have to invert the logic using NOT and skip over the
conditional instruction unless the condition is met:
IF NOT x < 20 THEN NoInc ' Don't increment y unless x < 20.
y = y + 1 ' Increment y if x < 20.
NoInc: ' Program continues.
You can also code a conditional GOSUB, as in “IF x = 100 THEN GOSUB
Centennial.” In PBASIC:
1
NOTE: On the BS1, parentheses
are not allowed within arguments.
Table 5.24: Conditional Logic
Operator's Truth-Table.
IF…THEN
CAN ONLY JUMP TO A
LABEL IF THE CONDITION IS TRUE
.
M
AKING A CONDITIONAL
GOSUB.
1
NOTE: The XOR operator is not
available on the BS1.
1
NOTE: The NOT operator is not
available on the BS1.
Содержание BASIC Stamp 1
Страница 1: ...BASIC Stamp Programming Manual Version 2 0c...
Страница 30: ...Introduction to the BASIC Stamps Page 28 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 34: ...Quick Start Guide Page 32 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 90: ...BUTTON BASIC Stamp Command Reference Page 88 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 118: ...END BASIC Stamp Command Reference Page 116 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 128: ...FREQOUT BASIC Stamp Command Reference Page 126 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 196: ...NAP BASIC Stamp Command Reference Page 194 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 206: ...OWIN BASIC Stamp Command Reference Page 204 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 214: ...OWOUT BASIC Stamp Command Reference Page 212 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 216: ...PAUSE BASIC Stamp Command Reference Page 214 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 226: ...POLLMODE BASIC Stamp Command Reference Page 224 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 232: ...POLLOUT BASIC Stamp Command Reference Page 230 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 236: ...POLLRUN BASIC Stamp Command Reference Page 234 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 240: ...POLLWAIT BASIC Stamp Command Reference Page 238 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 262: ...RCTIME BASIC Stamp Command Reference Page 260 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 274: ...RUN BASIC Stamp Command Reference Page 272 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 310: ...SEROUT BASIC Stamp Command Reference Page 308 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 324: ...STOP BASIC Stamp Command Reference Page 322 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 340: ...ASCII Chart Page 338 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 342: ...Reserved Words Page 340 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 346: ...Conversion Formatters Page 344 BASIC Stamp Programming Manual 2 0b www parallaxinc com...