lookup vs. readtable

Pongo

Senior Member
What are the criteria for choosing between lookup and readtable?

At the moment I only have a lookup of 12 variables so it probably doesn't matter very much, but I would like to know for future reference.
 

hippy

Technical Support
Staff member
The usual criteria is if there is a need for faster speed or not. If so then READTABLE and READ will be faster than LOOKUP.

If speed isn't that important then either can be used, though LOOKUP takes longer to execute the more entries there are.

On M2 PICAXE chips, adding READTABLE may cause the download to take longer.

If you can post your code there may be better or more pertinent advice. It's not clear how you mean by "a lookup of 12 variables". If you mean 12 LOOKUP commands it is probably not an issue, but if LOOKUP of 12 variables -

LookUp b20, ( b1, b2, b3, b4, ... b11, b12 ), b21

You could not put those variables in TABLE.
 

Pongo

Senior Member
Thanks for the speed comment, that's helpful. So far my test includes 4 lookup commands on a 20X2 @ 32 MHz and that doesn't seem to be a problem.

lookup D2,(63,6,91,79,101,109,125,7,127,111,128,0,2),D1

That's what I meant, although I see that's 13 <oops>

I'm not sure what you mean about TABLE, I'm using e.g.

table 16, (13,12,11,10,8,14,13,12,10,9,1,14,12,11,9,10,14,13,12,11,9)

without any apparent issues.
 

hippy

Technical Support
Staff member
It's if you had wanted ...

table 16, ( b0, b1, ... )

then you would have not been able to do that. For numeric constants and characters it's perfectly fine.
 
Top