This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

result of grp.tag
#1
Hi,

What is the most efficient way of testing for the table object returned by grp.tag?  ie is it better to test for the existence of the table or the length or is there something else?


Code:
if (event.type=='groupwrite') then
 local myvl = grp.tag({'VL0','vl'},'all')
 if(myvl) then --existence
   myvl:write(event.getvalue())
 end
 local myls = grp.tag({'VL0','ls'},'all')
 if(#myls>0) then  --length
   if (event.getvalue() > 0) then
     myls:write(true)
   else
     myls:write(false)
   end
 end
end
Thanks,


Roger
Reply
#2
grp.tag always returns a table if valid tag, tag list or tag table is passed. So the correct way is to check table length (#mytable). Still, you can call write and other methods on an empty table returned by grp.tag, it just won't do anything.
Reply
#3
ok thanks
Reply


Forum Jump: