lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I'm just getting to grips with this fascinating language, and starting to
explore its use as an extension language to my program.

In my program I have some structures that can best be described as a main
record and a set of subrecords. I am trying to model this as a lua table,
using textual indices for the main record fields and numeric indices each
giving another table representing the subrecord. However, each table is
actually empty, using tag methods within the C code to actually evaluate
the index and return the correct value.

In general this seems to work well; however when I try to use foreachi to
step through the subrecords it says "nothing there", as the code in
lbuiltin.c works from lua's internal knowledge of the table content.
foreach would have similar problems, but I can see that it would be
difficult to come up with a scheme for lua to "ask" for all the text
indices.

Is there a way of getting this scheme to work with foreachi, or do I have
to write my own C function to do a similar job? Or is there some better way
of modelling this situation?

Thanks

Mike Goodey (G0GJV)