Logic Machine Forum
Object write with - 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: Object write with (/showthread.php?tid=4515)



Object write with - 2MAX - 19.01.2023

Hi, can You help me, the red part of script doesnt work to me. I need if STAV==1, to wait 5times x 10sec if it change to 0.

STAV=grp.getvalue("10/1/181")
pocet=5

if (event.getvalue()==true)
  then
  if(STAV==0)
    then
    grp.write("10/0/0", true)
    end
  else
  repeat
    os.sleep(10)
    pocet=pocet-1
    if(STAV==0)
      then
       grp.write("10/0/0", true)
   end
  until (pocet==0)
end


RE: Object write with - tigi - 19.01.2023

I think the script will not work because of your 2nd IF statement and the declaration of STAV at the beginning.

if STAV = 0 then do something, but if STAV is not zero do something ELSE.
Then in that ELSE statement you check in your REPEAT loop if STAV is 0 again, but you ended there because STAV was something else than zero and you don't re-poll the STAV value, so you'll never meet that condition. I guess...


RE: Object write with - 2MAX - 20.01.2023

(19.01.2023, 20:07)tigi Wrote: I think the script will not work because of your 2nd IF statement and the declaration of STAV at the beginning.

if STAV = 0 then do something, but if STAV is not zero do something ELSE.
Then in that ELSE statement you check in your REPEAT loop if STAV is 0 again, but you ended there because STAV was something else than zero and you don't re-poll the STAV value, so you'll never meet that condition. I guess...

I think so this is problem with update object, but how to do update of STAV during repeat?


RE: Object write with - admin - 20.01.2023

You need to add another grp.getvalue call before checking the value.