PDA

View Full Version : Help with look up tables please



opticaltrigger
- 16th June 2010, 22:39
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.

mackrackit
- 16th June 2010, 23:29
This page has a couple sample programs
http://www.melabs.com/resources/samples-pbp-general.htm
And of course the manual...

mackrackit
- 17th June 2010, 02:53
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.

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.

Lookup B11,[898,895,892,889,886,883,879,876,873,870,867,863,86 0,857,854,850,847],B10
In this case if B11 = 1 then B10 would equal 895.
B11 = 16 then B10 would equal 847.

opticaltrigger
- 19th June 2010, 01:54
Once again thanks very much Macrackit.Much appreciated.

O.T.