lookup/lookupz
RS_Jim
Posts: 1,768
in Propeller 2
i need to use lookupz to find an indexed value in a list. Can I put the list in a DAT statment in the top Obj? If so, how?
Jim
Comments
Think I see some code for that here:
https://forums.parallax.com/discussion/174021/lookupz-index-v1-v2-v3-etc-value-what-are-ranges
If you have the list in a DAT section, you don't use LOOKUP(Z), you just access the list as an indexed array element:
This works also with WORD and LONG lists.
Andy
@Ariba Andy, I set up my DAT table in my top object and then tried to access it from my child object, no luck, it wont compile, saying that my table is not an array.. If I move the table to the child obj, then it compiles fine. I must be missing something, any suggestions? the whole idea was to get the data in the top object to make the child more universal in its usage.
Jim
Jim,
You are going to need to pass a pointer to the parent array to the child object. You could put a method in the child called set_table().
...where p_table is a global long in the child. Call this from the parent:
Now you can do this in the child:
You need to pass the address of the table to the child object. And there access the table with byte[], word[], or long[]
Something like that: