Propeller Manual

Table Of Contents
2: Spin Language Reference – LOOKDOWN, LOOKDOWNZ
Propeller Manual v1.1 · Page 137
The GetIndex method in this example uses LOOKDOWN to find Value and returns the index
where it was found in the ExpressionList, or 0 if not found. The
ShowList method calls
GetIndex repeatedly with different values and prints the resulting index on a display.
Assuming
Print is a method that displays a value, this example will print 1, 2, 3, 4, 5, 6 and 7
on a display.
If
LOOKDOWNZ were used instead of LOOKDOWN this example would print 0, 1, 2, 3, 4, 5, and 6 on
a display.
If Value is not found,
LOOKDOWN, or LOOKDOWNZ, returns 0. So if one of the lines of the ShowList
method was, Print(GetIndex(50)), the display would show 0 at the time it was executed.
If using
LOOKDOWNZ, keep in mind that it may return 0 if either Value was not found or Value is
at index 0. Make sure this will not cause an error in your code or use
LOOKDOWN instead.