Specifications
BASIC Stamp II
Page 278 • BASIC Stamp Programming Manual 1.8 • Parallax, Inc.
Lookdown
LOOKDOWN
value,{comparisonOp,}[value0, value1,...valueN],resultVariable
Compare a value to a list of values according to the relationship speci-
fied by the comparison operator. Store the index number of the first
value that makes the comparison true into resultVariable. If no value in
the list makes the comparison true, resultVariable is unaffected.
•
Value
is a variable or constant to be compared to the values in the
list.
•
ComparisonOp
is optional and maybe one of the following:
= equal
<> not equal
> greater than
< less than
>= greater than or equal to
<= less than or equal to
If no comparison operator is specified, PBASIC2 uses equal (=).
•
Value0
, value1... make up a list of values (constants or variables)
up to 16 bits in size.
•
ResultVariable
is a variable in which the index number will be
stored if a true comparison is found.
Explanation
Lookdown works like the index in a book. You search for a topic and
the index gives you the page number. Lookdown searches for a value
in a list, and stores the item number of the first match in a variable. For
example:
value var byte
result var nib
value = 17
result = 15
LOOKDOWN value,[26,177,13,1,0,17,99],result
debug "Value matches item ",dec result," in list"










