LOOKDOWN - BASIC Stamp Command Reference
Page 180
•
BASIC Stamp Programming Manual 2.0b
•
www.parallaxinc.com
ComparisonOp Symbol
Description
=
Find the first value Target is equal to
<>
Find the first value Target is not equal to
>
Find the first value Target is greater than
<
Find the first value Target is less than
>=
Find the first value Target is greater than or equal to
<=
Find the first value Target is less than or equal to
A common application for LOOKDOWN is to use it in conjunction with
the BRANCH command to create selective jumps based on a simple
variable input:
Cmd VAR BYTE
Cmd = "M"
LOOKDOWN Cmd, ["SLMH"], Cmd
BRANCH Cmd, [_Stop, _Low, _Medium, _High]
DEBUG "Command not in list"
END
_Stop: DEBUG "stop"
END
_Low: DEBUG "low"
END
_Medium: DEBUG "medium"
END
_High: DEBUG "high"
END
In this example, Cmd contains “M” (ASCII 77). LOOKDOWN finds that
this is item 2 of a list of one-character commands and stores 2 into Cmd.
BRANCH then goes to item 2 of its list, which is the program label
“_Medium” at which point DEBUG prints “medium” on the PC screen.
This is a powerful method for interpreting user input, and a lot neater
than the alternative IF...THEN instructions.
Another great use of LOOKDOWN is in combination with LOOKUP to
"map" non-contiguous sets of numbers together. For example, you may
have an application where certain numbers are received by the BASIC
Stamp and, in response, the BASIC Stamp needs to send a specific set of
numbers. This may be easy to code if the numbers are contiguous, or
follow some know algebraic equations… but what if they don't? The table
U
SING
LOOKDOWN
WITH
BRANCH
TO JUMP BASED ON VALUES
.
NOTE: For BS1's, change line 1 to:
SYMBOL Cmd = B0
And replace the [ and ] symbols
with ( and ) in lines 4 and 5.
U
SING
LOOKDOWN
WITH
LOOKUP
TO
"
MAP
"
NON
-
CONTIGUOUS SETS OF
NUMBERS
.
Table 5.36: LOOKDOWN
Comparison Operators.
Содержание 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...