# Gateway Event Script - Tag Value Change

**URL:** <https://forum.inductiveautomation.com/t/gateway-event-script-tag-value-change/75475>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [June 23, 2023, 7:32pm UTC](https://forum.inductiveautomation.com/t/gateway-event-script-tag-value-change/75475 "2023-06-23T19:32:47Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [June 30, 2023, 9:57pm UTC](https://forum.inductiveautomation.com/t/gateway-event-script-tag-value-change/75475/22 "2023-06-30T21:57:09Z")

</div>

> [@nminchin](#):
>
> I don't believe gateway tag change scripts have an initial change

There is an initialChange flag, but it isn’t accessed the same way.

Here is the 8.1 manual listing:  
[https://docs.inductiveautomation.com/display/DOC81/Gateway+Event+Scripts](https://docs.inductiveautomation.com/display/DOC81/Gateway+Event+Scripts)

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [June 30, 2023, 10:00pm UTC](https://forum.inductiveautomation.com/t/gateway-event-script-tag-value-change/75475/23 "2023-06-30T22:00:09Z")

</div>

Well, that's good to know, I guess checking for None is essentially the same thing, but more painful!

---

<div class="post-metadata">

**Author:** ![Peter\_Gietl](https://avatars.discourse-cdn.com/v4/letter/p/edb3f5/32.png) [@Peter\_Gietl](https://forum.inductiveautomation.com/u/Peter_Gietl)\
**Post date:** [June 30, 2023, 10:06pm UTC](https://forum.inductiveautomation.com/t/gateway-event-script-tag-value-change/75475/24 "2023-06-30T22:06:28Z")

</div>

I'm under the impression that event handlers are designed to automatically execute in response to certain events. Therefor, in this case the `tagChange` function would execute whenever a tag change event occurs in the Ignition system. So, even though the `tagChange` function is not being called in the script, it's being called by Ignition whenever a tag change event occurs. To my understanding, this is why you can put logic inside the `tagChange` function to respond to tag changes, and Ignition will automatically execute that logic.

If I'm wrong about this, thank you for correcting me.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [June 30, 2023, 10:13pm UTC](https://forum.inductiveautomation.com/t/gateway-event-script-tag-value-change/75475/25 "2023-06-30T22:13:46Z")

</div>

> [@Peter\_Gietl](#):
>
> If I'm wrong about this, thank you for correcting me.

You assign a trigger tag to the event, once a change event is detected the script defined inside of the script tab is executed. From there the script is executed just as any jython would.

I’m working under the assumption that the new script you provided is inside of the script tab. If that is indeed the case then you have defined a function inside of that script and it isn’t being called, therefore none of the code within its scope is being executed.

For instance this code inside of that script tab will do nothing:

```auto
def tagChange(event):
    for i in range(10):
        print I

```

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [June 30, 2023, 11:04pm UTC](https://forum.inductiveautomation.com/t/gateway-event-script-tag-value-change/75475/26 "2023-06-30T23:04:42Z")

</div>

> [@lrose](#):
>
> For instance this code inside of that script tab will do nothing:

Well, not _nothing_ technically. It'll define the function, but then nothing else. It won't be called/executed

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 30, 2023, 11:13pm UTC](https://forum.inductiveautomation.com/t/gateway-event-script-tag-value-change/75475/27 "2023-06-30T23:13:01Z")

</div>

To eliminate any confusion, a screenshot of the code editor and what your code looks like within it would be helpful in this case.

[Previous page](https://forum.inductiveautomation.com/t/gateway-event-script-tag-value-change/75475.md?page=1)
