# Perspective interactions with Gateway Scripts

**URL:** <https://forum.inductiveautomation.com/t/perspective-interactions-with-gateway-scripts/45495>\
**Category:** Ignition\
**Created:** [April 12, 2021, 3:44pm UTC](https://forum.inductiveautomation.com/t/perspective-interactions-with-gateway-scripts/45495 "2021-04-12T15:44:19Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![agriner](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@agriner](https://forum.inductiveautomation.com/u/agriner)\
**Post date:** [April 12, 2021, 3:44pm UTC](https://forum.inductiveautomation.com/t/perspective-interactions-with-gateway-scripts/45495/1 "2021-04-12T15:44:19Z")

</div>

Hi, I’m looking for some help in setting up an interaction between a component in Perspective (an on/off toggle) and a Gateway Timer Script. The script is setup to generate a series of tasks (DB insert operations basically) every hour and I’d like that script to be something that can be turned on or off by a user using the toggle. Can this be done?

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [April 12, 2021, 4:26pm UTC](https://forum.inductiveautomation.com/t/perspective-interactions-with-gateway-scripts/45495/2 "2021-04-12T16:26:02Z")

</div>

So you want it so your gateway timer script only runs if and only if that toggle button is in the “on” position essentially?

I would make a Gateway Memory tag thats a bool or int, lets call it `enable_timer_script`, and in your perspective project, the value of your button is bound to this tag/writes to it. So if your button is on, the tag = 1 or True (depending on what type you used).

Then, in your gateway timer script, I would start off the entire thing with

```auto
if system.tag.value("enable_timer_script").value:
    # Do rest of script

```

Unless I am misinterpreting what you are asking for.

---

<div class="post-metadata">

**Author:** ![agriner](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@agriner](https://forum.inductiveautomation.com/u/agriner)\
**Post date:** [April 12, 2021, 5:04pm UTC](https://forum.inductiveautomation.com/t/perspective-interactions-with-gateway-scripts/45495/3 "2021-04-12T17:04:28Z")

</div>

That’s exactly what I’m looking to do.  
Thanks so much! I’ll that out.

---

<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:** [April 12, 2021, 5:07pm UTC](https://forum.inductiveautomation.com/t/perspective-interactions-with-gateway-scripts/45495/4 "2021-04-12T17:07:17Z")

</div>

A small note:

> [@bkarabinchak.psi](#):
>
> ```python
> if system.tag.value("enable_timer_script").value:
> # Do rest of script
> 
> ```

This should be

```python
if system.tag.readBlocking(['path to enable_timer_script'])[0].value:

```

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [April 12, 2021, 5:10pm UTC](https://forum.inductiveautomation.com/t/perspective-interactions-with-gateway-scripts/45495/5 "2021-04-12T17:10:21Z")

</div>

Can you explain why in this instance? I thought `readBlocking` was only necessary if you had a list of tags you needed to get at the same time? Since this is only one tag, I thought `system.tag.read().value` would work here.

Also, I meant `system.tag.read("enable_timer_script").value`, not `system.tag.value("enable_timer_script").value`

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [April 12, 2021, 5:20pm UTC](https://forum.inductiveautomation.com/t/perspective-interactions-with-gateway-scripts/45495/6 "2021-04-12T17:20:30Z")

</div>

system.tag.read is technically deprecated

---

<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:** [April 12, 2021, 5:22pm UTC](https://forum.inductiveautomation.com/t/perspective-interactions-with-gateway-scripts/45495/7 "2021-04-12T17:22:48Z")

</div>

I was mainly meaning that system.tag.value didn’t exist. However, as @bschroeder said, system.tag.read has been deprecated, so any new scripts should use the appropriate functions for the case.

`system.tag.readBlocking(), system.tag.readAsync(), system.tag.writeBlocking(), system.tag.writeAsync()`

---

<div class="post-metadata">

**Author:** ![agriner](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@agriner](https://forum.inductiveautomation.com/u/agriner)\
**Post date:** [April 12, 2021, 5:30pm UTC](https://forum.inductiveautomation.com/t/perspective-interactions-with-gateway-scripts/45495/8 "2021-04-12T17:30:58Z")

</div>

One more question actually:  
Can new system tags be freely created? ‘Create new tag’ options are grayed out when using the System tag provider for me.  
If not, I’m wondering if a Project scoped tag would work just as well even though it’s a Gateway script. that’ll be referencing the tag. This should be the only project running on the Gateway so I don’t see a conflict there.

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [April 12, 2021, 5:32pm UTC](https://forum.inductiveautomation.com/t/perspective-interactions-with-gateway-scripts/45495/9 "2021-04-12T17:32:46Z")

</div>

So tags are gateway scoped not project scoped (Except for Vision Client tags).

System tags are pre-defined tags that the gateway creates, not tags that are available across the entire system. Each tag, except for Vision Client Tags, is available across all projects on the gateway.
