tag group write, only different data - Printable Version +- Logic Machine 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: tag group write, only different data (/showthread.php?tid=486) |
tag group write, only different data - gjniewenhuijse - 05.12.2016 Hello, I have a script that writes values to a group addresses: AllStatus = grp.tag('test') AllStatus:write( true ) I want to write only to that addresses that have different data then the value to write. In this case only write value true to addresses with tag 'test' and value false. RE: tag group write, only different data - admin - 05.12.2016 Code: function tagcheckwrite(tag, value) RE: tag group write, only different data - mlaudren - 05.12.2016 if you look for the object AllStatus, you'll find it's an array with all object. You can do a loop on this array and write the value only if it's not the same Will look something like: for _, item in ipairs(AllStatus) do if item.value != newvalue then grp.write(item.address, newvalue end end Edit: Admin send a reply just before my. take his |