# Linking Tags Using a Gateway Tag Change Script

**URL:** <https://forum.inductiveautomation.com/t/linking-tags-using-a-gateway-tag-change-script/92630>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [July 1, 2024, 2:38pm UTC](https://forum.inductiveautomation.com/t/linking-tags-using-a-gateway-tag-change-script/92630 "2024-07-01T14:38:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Peter\_Frazier](https://avatars.discourse-cdn.com/v4/letter/p/ec9cab/32.png) [@Peter\_Frazier](https://forum.inductiveautomation.com/u/Peter_Frazier)\
**Post date:** [July 1, 2024, 2:38pm UTC](https://forum.inductiveautomation.com/t/linking-tags-using-a-gateway-tag-change-script/92630/1 "2024-07-01T14:38:56Z")

</div>

Using a gateway tag change script, I am trying to update a tag's value (we'll call this tag\_2) when another tag changes (tag\_1). However, I only want to update tag\_2's value when the value of tag\_1 is an integer between 1 and 8. Any suggestions?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/7/875e1e240fe9fda9a84ba246604df53407cfafb7.png)

---

<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:** [July 1, 2024, 2:48pm UTC](https://forum.inductiveautomation.com/t/linking-tags-using-a-gateway-tag-change-script/92630/2 "2024-07-01T14:48:49Z")

</div>

1. Don't import system
2. Why cast a value, and then immediately check if it is an instance of the type you just cast it to? If you're trying to verify that the casting was successful, then a `try, except` would be more appropriate.

If you want the `lane_number` tag to be an integer, then make that tag's type an integer, then there is no need to cast it. Don't store values as strings when you want to use them as a different type.

This code should simply be:

```python
if 0 < newValue.value <= 8:
    system.tag.writeBlocking(["path to tag"],[newValue.value])

```
