11.07.2015 Views

PICBASIC PLUS LITE Manual - Profe Saul

PICBASIC PLUS LITE Manual - Profe Saul

PICBASIC PLUS LITE Manual - Profe Saul

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>PICBASIC</strong> <strong>PLUS</strong> Compiler5.37. LOOKDOWNSyntax : Variable = LOOKDOWN Index , [ Constant { , Constant…etc } ]Overview :Operators :Example :Search constants(s) for index value. If index matches one of the constants,then store the matching constant’s position (0–N) in variable. Ifno match is found, then the variable is unaffected.Variable is a user define variable that holds the result of the search.Index is the variable/constant being sought.Constant(s),... is a list of values. The target value is compared tothese valuesDIM Value as BYTEDIM Result as BYTEValue = 177‘ The value to look for in the listResult = 255 ‘ Default to value 255Result = LOOKDOWN Value , [75,177,35,1,8,29,245]PRINT "Value matches " , @Result , " in list"In the above example, PRINT displays, “Value matches 1 in list” becauseVALUE (177) matches item 1 of [75,177,35,1,8,29,245]. Notethat index numbers count up from 0, not 1; that is in the list[75,177,35,1,8,29,245], 75 is item 0.If the value is not in the list, then RESULT is unchanged.Notes :LOOKDOWN is similar to the index of a book. You search for a topicand the index gives you the page number. Lookdown searches for avalue in a list, and stores the item number of the first match in a variable.LOOKDOWN also supports text phrases, which are basically lists ofbyte values, so they are also eligible for Lookdown searches: -DIM Value as BYTEDIM Result as BYTEValue = 101‘ ASCII “e”. the value to look for in the listResult = 255 ‘ Default to value 255Result = LOOKDOWN Value , ["Hello World"]In the above example, RESULT will hold a value of 1, which is the positionof character ‘e’See also :LOOKDOWNL, LOOKUP, LOOKUPL74Copyright Crownhill 2001

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!