I'm using IUP with Lua. I want to store some data in the IUP tree structure. So now the problem is, how can I search the tree to see if a certain entry already exists?
Unfortunately, the node titles of the tree only seem to be accessible by using
mytree.title1
mytree.title2
and so on.
It would be easy if the nodes were accessible by something like
mytree.title(1)
mytree.title(2)
Then I could just use a for loop. But this doesn't work.
Table field names are just string keys, so you can put them together algorithmically.
for i = 1, 10 do
print(mytree['title' .. i])
end
Look up string.format
if you need to format the number into the field name in some non-default way.