# Is there a simple way to read a memory tag from another gateway

**URL:** <https://forum.inductiveautomation.com/t/is-there-a-simple-way-to-read-a-memory-tag-from-another-gateway/54116>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [December 14, 2021, 8:23pm UTC](https://forum.inductiveautomation.com/t/is-there-a-simple-way-to-read-a-memory-tag-from-another-gateway/54116 "2021-12-14T20:23:01Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![smcfarlane](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/smcfarlane/32/42150_2.png) [@smcfarlane](https://forum.inductiveautomation.com/u/smcfarlane)\
**Post date:** [December 14, 2021, 8:23pm UTC](https://forum.inductiveautomation.com/t/is-there-a-simple-way-to-read-a-memory-tag-from-another-gateway/54116/1 "2021-12-14T20:23:01Z")

</div>

I have two gateways, one set up as development and the other production. They are, essentially, exact copies of each other. I have a boolean that I want to toggle true or false with a button but I want to have the same boolean tag on the other gateway always be the opposite of that. So the pseudo code would be

```auto
if gateway = development
   set development\[default]boolean = NOT development\[default]boolean
   set production\[default]boolean = NOT development\[default]boolean

if gateway = production
   set production\[default]boolean = NOT production\[default]boolean
   set development\[default]boolean = NOT production\[default]boolean

```

I know how to read the gateway the client is on. What I don’t know is how to access the tag on the other gateway. I don’t want to use a remote tag provider pointing from one gateway to the other because when I migrate from development to production thats just one more manual change I have to make. I’d like to find a way to make this script generic so it doesn’t care what gateway it lives on.

Is there a way to use system.tag.readBlocking or readAsynch to read a tag on another gateway?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 14, 2021, 8:37pm UTC](https://forum.inductiveautomation.com/t/is-there-a-simple-way-to-read-a-memory-tag-from-another-gateway/54116/2 "2021-12-14T20:37:51Z")

</div>

You should be using a file that lives outside the `data/` hierarchy (so it won’t be in a gateway backup) that contains that kind of information. Or an environment variable. Read it at gateway startup and write the tag.

---

<div class="post-metadata">

**Author:** ![smcfarlane](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/smcfarlane/32/42150_2.png) [@smcfarlane](https://forum.inductiveautomation.com/u/smcfarlane)\
**Post date:** [December 14, 2021, 8:53pm UTC](https://forum.inductiveautomation.com/t/is-there-a-simple-way-to-read-a-memory-tag-from-another-gateway/54116/3 "2021-12-14T20:53:03Z")

</div>

Interesting suggestion. Could I modify the environment variable while the client is running or is that something I could only read at startup?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 14, 2021, 8:55pm UTC](https://forum.inductiveautomation.com/t/is-there-a-simple-way-to-read-a-memory-tag-from-another-gateway/54116/4 "2021-12-14T20:55:02Z")

</div>

If you are writing it to a memory tag to make it available throughout the gateway, I don’t see why you can’t overwrite it. (But note that edits to the project containing the startup script will make it execute again.)

(Environment variables are static. And only readable at the gateway. Vision clients and the designer wouldn’t have access.)

---

<div class="post-metadata">

**Author:** ![smcfarlane](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/smcfarlane/32/42150_2.png) [@smcfarlane](https://forum.inductiveautomation.com/u/smcfarlane)\
**Post date:** [December 14, 2021, 8:57pm UTC](https://forum.inductiveautomation.com/t/is-there-a-simple-way-to-read-a-memory-tag-from-another-gateway/54116/5 "2021-12-14T20:57:32Z")

</div>

Think we lost each other. I have two gateways, each gateway needs to know the state of its own boolean and the one on the other gateway. I need both gateways to be able to toggle their own and then write to the remote gateway to modify its tag as well.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 14, 2021, 8:59pm UTC](https://forum.inductiveautomation.com/t/is-there-a-simple-way-to-read-a-memory-tag-from-another-gateway/54116/6 "2021-12-14T20:59:57Z")

</div>

Ah, missed the live sync. You’ll probably need to use WebDev to expose a way to have one gateway call the other. Or put them in a gateway network together and message to each other. Writing from two directions tends to be racy, though.

---

<div class="post-metadata">

**Author:** ![smcfarlane](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/smcfarlane/32/42150_2.png) [@smcfarlane](https://forum.inductiveautomation.com/u/smcfarlane)\
**Post date:** [December 14, 2021, 9:01pm UTC](https://forum.inductiveautomation.com/t/is-there-a-simple-way-to-read-a-memory-tag-from-another-gateway/54116/7 "2021-12-14T21:01:26Z")

</div>

Based on what I’ve read, messaging may be the proper method. I appreciate the input.
