Delay system.tag.write in component scripting

I want to delay a system.tag.write for 3 to 5 secs after a mouse click. I want to write a zero in to the tag.

Wrap it in system.util.invokeLater in the actionPerformed event. Replace “[Client]testFloat” in code below with the actual path to your tag (right-click on tag in Tag Browser and choose Copy Tag Path):

# Define a function to call after a delay
def writeLater():
   import system
   system.tag.write("[Client]testFloat", 0)
# Tell the system to invoke the "writeLater" function after 3 seconds (3000 ms)
system.util.invokeLater(writeLater, 3000)
3 Likes

that worked great! thanks for the help

Hello,

Can this work in a global script? I tried it and it doesn’t delay writing to the tag.

Thanks