Accessing Tags through button script

Hi,

I have a button in which I am trying to change a tag value as per certain conditions. The tag values changes multiple times during the execution of the script. I am trying to see these variations on designer window . I have bound the tag value to a component . I am able to see only the final value on the component… (only after the execution of the button script completely). How to fix this problem? I want to see the changes on the tag value on the window.

Thank you.

Does the value need to be a tag?

What I mean is this: Is there an external device that this script is changing?

Scripts execute in ms or less, so it doesn’t often make since to change a tag value multiple times throughout the script. This behavior is better served by a variable or window/component parameter.

The gui won't update until after the script is finished. This is because the foreground thread of the script is the gui thread.

If this is a necessary thing to do, consider using @pturmel's later.py scripts.

2 Likes

Thank you for the response. There is no external device. I am working with secs gem ( the inbuilt simulator is used) where a button triggers a series of event runs. So I want to see a status change on a particular tag. So, it needs to be updated in accordance to the event run. The tag value is getting updated, but I can’t see it on the designer window as it shows only the final value ie. only after completing the whole script inside the button. Is there any way to fix this?

You're going to have to do this on an Asynchronous thread. Take a look at the post of @pturmel's that @JordanCClark linked for a good discussion on this.

There is no bug in Ignition to fix. The error is in your use of an event routine for a long-running task. You cannot do this. (Not in any modern programming language--not just Ignition.) There are two approaches you can take for a problem like this:

  1. Run the long task in an asynchronous thread, using the techniques in the linked topic to interact with the GUI, or

  2. Break your task into many individual operations that run quickly as part of an appropriate trigger event, typically with an accompanying state machine.

In general, if you use any form of sleep or busy looping in an event routine, you've screwed up.

2 Likes

Thank you. I will do that

Thank you. I will try this

Thank you. I will try with this method.