Positron Compiler Documentation

LookUp

Positron16 · Revision 1.1.3.5 · PDF page 399

Assignment Variable = LookUp Index, [ Constant {, Constant…etc } ]

Look up the value specified by the index and store it in variable. If the index exceeds the highest index value of the items in the list, then variable remains unchanged.

Index may be a constant of variable. This is the item number of the value to be retrieved from the list. Constant(s) may be any 8-bit value (0-255). A maximum of 65536 values may be placed between the square brackets. Assignment Variable is a user define variable that holds the result of the search.

' Create an animation of a spinning line on an LCD.
  Device = 24HJ128GP502      ' Select the device to compile for
  Declare Xtal = 16

  Dim Index as Byte
  Dim Frame as Byte

  Cls                       ' Clear the LCD
  Do
     For Index = 0 to 3      ' Create a loop of 4
       Frame = LookUp Index, [ "|\-/" ]  ' Table of animation characters
       Print At 1, 1, Frame  ' Display the character
       DelayMs 200           ' So we can see the animation
     Next                    ' Close the loop
   Loop                       ' Repeat forever

Index starts at value 0. For example, in the LookUp command below. If the first value (10) is required, then index will be loaded with 0, and 1 for the second value (20) etc.

  Var1 = LookUp Index, [10, 20, 30]

See also : Dim, cPtr8, cPtr16, cPtr24, cPtr32, Cread8, Cread16, Cread24, Cread32, Edata, Eread, LookDown, LookDownL, LookUpL.

View original PDF page 399Open page in PDFOriginal PDF page 399