LogicMachine Forum
Table of all objects - Printable Version

+- LogicMachine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Table of all objects (/showthread.php?tid=1936)



Table of all objects - Thomas - 28.02.2019

Hi
How to get table of all objects?
Or better how to obtain table of all objects which doesn't contain a specific tag?
I tried
grp.tag()
grp.tag({})
grp.tag('')
grp.tag(nil)

but with no luck


RE: Table of all objects - buuuudzik - 28.02.2019

I think this could be a solution:

Code:
tag = "exclude" objects = grp.all() filteredObjects = {} for _,o in ipairs(objects) do  if o.tagcache.find(tag) then table.insert(filteredObjects, o) end end


You can also use db query:

Code:
tag = "exclude" sqlQuery = 'SELECT * FROM objects WHERE tagcache NOT LIKE "%" .. tag .. "%"' filteredObjects = db:getall(sqlQuery) -- if you need a value then you must also decode a value based on datatype for _, o in ipairs(objects) do   o.value = knxdatatype.decode(o.datahex, o.datatype) end



RE: Table of all objects - Thomas - 28.02.2019

Thank you. I missed grp.all() exists.