Help with look up tables please


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2009
    Location
    Somerset England
    Posts
    10

    Default Help with look up tables please

    Hi guys,
    I want to start and program using lookup tables and was hoping somone might be able to point me towards some material I can read that will give me an idea of how to start using them.I would like to grasp how they work and how they are constructed etc.
    Any help would be much apprieciated.

    All the best
    O.T.

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    This page has a couple sample programs
    http://www.melabs.com/resources/samples-pbp-general.htm
    And of course the manual...
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Looking at this example.. maybe it is not self explanatory.

    In this example the variable B11 is being looked up. B11 can have the value of 0 through 16.
    The LOOKUP table has 17 characters in the string.
    If B11 = 0 then the ASCii character 0 is given to the variable B10.
    If B11 = 5 then the ASCii character 4 is given to the variable B10.
    Code:
    HexW:
       Gosub HexB13            ' Print MSB
       B13 = B12               ' Print LSB
     
    HexB13:
       B11 = B13 / 16          ' Print MSB
       Gosub HexB11
       B11 = B13 & 15
     
    HexB11:
       Lookup B11,["0123456789ABCDEF"],B10 ' B10 = HEX$(B11)
       Serout SO,N2400,[B10]
       Return
    If you wanted to give a numeric value to B10 based on B11 then the LOOKUP table could be like this.
    Code:
    Lookup B11,[898,895,892,889,886,883,879,876,873,870,867,863,860,857,854,850,847],B10
    In this case if B11 = 1 then B10 would equal 895.
    B11 = 16 then B10 would equal 847.
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Jun 2009
    Location
    Somerset England
    Posts
    10


    Did you find this post helpful? Yes | No

    Default

    Once again thanks very much Macrackit.Much appreciated.

    O.T.

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts