![]() |
|
adding tags to group addresses that have no tag - 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: adding tags to group addresses that have no tag (/showthread.php?tid=4082) |
adding tags to group addresses that have no tag - asgeirsb - 07.06.2022 Hi, I've made a little script that searches for a string on addresses with the tags 'CL'. Then I replace a string with another and and want to add 'AUTO' tag to those adresses that have no tags from before. addresses with RT_MODE has the tag 'CL' and addresses with LL_COLORVAL does not have any tag The script works, but not allways. So if theres alot of addresses that doesn't have a tag like 70-90% of them gets the tag. Can anyone see through my script and see if its any issues with it? Code: myobjects = grp.tag('CL')
--log(myobjects[1])
for index, value in pairs(myobjects) do
if string.find(value.name, 'RT_MODE') then
b = string.gsub(value.name, "RT_MODE", "LL_COLORVAL")
x = grp.find(b)
if x.tagcache == '' then grp.addtags(b, 'AUTO') end
end
endRE: adding tags to group addresses that have no tag - admin - 07.06.2022 Check Error logs. If x object cannot be found you will get an error. I would change it like this: Code: if x and not string.find(x.tagcache or '', 'AUTO') then
grp.addtags(b, 'AUTO')
end |