# Writing to tag values on a gateway timer script (Ignition v7.9.6)

**URL:** <https://forum.inductiveautomation.com/t/writing-to-tag-values-on-a-gateway-timer-script-ignition-v7-9-6/40309>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [November 4, 2020, 7:13pm UTC](https://forum.inductiveautomation.com/t/writing-to-tag-values-on-a-gateway-timer-script-ignition-v7-9-6/40309 "2020-11-04T19:13:21Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![kade.castille](https://avatars.discourse-cdn.com/v4/letter/k/f05b48/32.png) [@kade.castille](https://forum.inductiveautomation.com/u/kade.castille)\
**Post date:** [November 4, 2020, 7:13pm UTC](https://forum.inductiveautomation.com/t/writing-to-tag-values-on-a-gateway-timer-script-ignition-v7-9-6/40309/1 "2020-11-04T19:13:22Z")

</div>

Hello,

I am attempting to write to a tag that runs on a gateway timer script. Essentially we are reading a value from a flowmeter and are attempting to obtain the flow from this meter for the entire month by adding it continually. I’m sure this is just a syntax issue but we can’t seem to get this to work. Any pointers would be appreciated, thanks!

 ![Gateway_timer_Script](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/9/d9a18524fb006abe1e03e8d99f100216d650223a.jpeg)

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [November 4, 2020, 7:25pm UTC](https://forum.inductiveautomation.com/t/writing-to-tag-values-on-a-gateway-timer-script-ignition-v7-9-6/40309/2 "2020-11-04T19:25:41Z")

</div>

you need to READ the tags for the values in scripting.

```auto
sum2 = system.tag.read('[default[PathToFlowTag').value + system.tag.read('[default[PathToSumTag').value
system.tag.write('[default]PathToSumTag',sum2)

```

---

<div class="post-metadata">

**Author:** ![kade.castille](https://avatars.discourse-cdn.com/v4/letter/k/f05b48/32.png) [@kade.castille](https://forum.inductiveautomation.com/u/kade.castille)\
**Post date:** [November 4, 2020, 7:46pm UTC](https://forum.inductiveautomation.com/t/writing-to-tag-values-on-a-gateway-timer-script-ignition-v7-9-6/40309/3 "2020-11-04T19:46:43Z")

</div>

Definitely a step in the right direction, I appreciate your response. The script still doesn’t seem to be working however, CURR\_MONTH\_FLOW\_TOT is still 0, so it’s not being written to. Sidenote: Are you sure that the “.value” in system.tag.read is written outside of the parenthesis, and not inside of it? I tried it both ways and it didn’t work either way, but I’m honestly just curious. I’m not really sure where to go from here, but I’m attaching a screenshot of the new script. Thanks!

 ![Gateway_timer_Script2](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/8/587a2d5e32ad3e37e88ec4d67891bfa8406cd466.jpeg)

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [November 4, 2020, 7:51pm UTC](https://forum.inductiveautomation.com/t/writing-to-tag-values-on-a-gateway-timer-script-ignition-v7-9-6/40309/4 "2020-11-04T19:51:13Z")

</div>

Reading a tag gives a ‘qualified value’ with three components, value being one of them.

Howerver, _Curr\_Month\_Flow_ does not need .value when you write to a tag.

---

<div class="post-metadata">

**Author:** ![kade.castille](https://avatars.discourse-cdn.com/v4/letter/k/f05b48/32.png) [@kade.castille](https://forum.inductiveautomation.com/u/kade.castille)\
**Post date:** [November 4, 2020, 8:07pm UTC](https://forum.inductiveautomation.com/t/writing-to-tag-values-on-a-gateway-timer-script-ignition-v7-9-6/40309/5 "2020-11-04T20:07:52Z")

</div>

Getting closer it seems, but still not quite there. Scripting in Ignition is definitely my weak point so I appreciate the assistance. I wonder if maybe it isn’t working because Curr\_Month\_Flow is a summation of two system.tag.read functions?

 ![Gateway_timer_Script3](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/f/cfb35ca70e35ed914f62d5570749c4585b8c59a7.jpeg)

---

<div class="post-metadata">

**Author:** ![bpreston](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@bpreston](https://forum.inductiveautomation.com/u/bpreston)\
**Post date:** [November 4, 2020, 8:11pm UTC](https://forum.inductiveautomation.com/t/writing-to-tag-values-on-a-gateway-timer-script-ignition-v7-9-6/40309/6 "2020-11-04T20:11:24Z")

</div>

You removed the .value from your reads, it needs to be there. Try:

```auto
Curr_Month_Flow = system.tag.read("[Gretna]Analog/CURR_MONTH_FLOW_TOT").value + system.tag.read("[Gretna]Analog/FIT_501/PV").value
system.tag.write("[Gretna]Analog/CURR_MONTH_FLOW_TOT",Curr_Month_Flow)

```

---

<div class="post-metadata">

**Author:** ![kade.castille](https://avatars.discourse-cdn.com/v4/letter/k/f05b48/32.png) [@kade.castille](https://forum.inductiveautomation.com/u/kade.castille)\
**Post date:** [November 4, 2020, 8:19pm UTC](https://forum.inductiveautomation.com/t/writing-to-tag-values-on-a-gateway-timer-script-ignition-v7-9-6/40309/7 "2020-11-04T20:19:24Z")

</div>

I had tried it earlier and it wasn’t working. So I removed them just to experiment, just forgot to put the “.value” back. I just tried exactly what bpreston suggested and still no dice. Maybe it’s possible that the problem at this point doesn’t lie in my syntax? I checked the gateway logs and no errors are showing up, but I see the same thing posted all over the log. Attaching screenshot, thanks everyone.

 ![Diagnostic_Log](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/f/afa45b1d0e4f3077a5be83c136f333818d137af9.jpeg)

---

<div class="post-metadata">

**Author:** ![kade.castille](https://avatars.discourse-cdn.com/v4/letter/k/f05b48/32.png) [@kade.castille](https://forum.inductiveautomation.com/u/kade.castille)\
**Post date:** [November 4, 2020, 8:20pm UTC](https://forum.inductiveautomation.com/t/writing-to-tag-values-on-a-gateway-timer-script-ignition-v7-9-6/40309/8 "2020-11-04T20:20:44Z")

</div>

I doubt the screenshot has much to do with my current issue. It doesn’t seem as though the timer script is even running though.

---

<div class="post-metadata">

**Author:** ![kade.castille](https://avatars.discourse-cdn.com/v4/letter/k/f05b48/32.png) [@kade.castille](https://forum.inductiveautomation.com/u/kade.castille)\
**Post date:** [November 4, 2020, 8:24pm UTC](https://forum.inductiveautomation.com/t/writing-to-tag-values-on-a-gateway-timer-script-ignition-v7-9-6/40309/9 "2020-11-04T20:24:36Z")

</div>

Yea it seems like the script doesn’t like the “+” in my script. I found out how to check the script error on the gateway and found this:

Traceback (most recent call last):  
File “\<TimerScript:IMTT\_Gretna\_2015/Current\_Total @5,000ms \>”, line 1, in   
TypeError: unsupported operand type(s) for +: ‘com.inductiveautomation.ignition.common.sqltags.BasicTagValue’ and ‘com.inductiveautomation.ignition.common.sqltags.BasicTagValue’

7.9.6 (b2018012914)  
Oracle Corporation 1.8.0\_161

---

<div class="post-metadata">

**Author:** ![bpreston](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@bpreston](https://forum.inductiveautomation.com/u/bpreston)\
**Post date:** [November 4, 2020, 8:28pm UTC](https://forum.inductiveautomation.com/t/writing-to-tag-values-on-a-gateway-timer-script-ignition-v7-9-6/40309/10 "2020-11-04T20:28:34Z")

</div>

Try testing it in your script console instead of the timer script.

Try:

```auto
mft = system.tag.read("[Gretna]Analog/CURR_MONTH_FLOW_TOT").value
fit = system.tag.read("[Gretna]Analog/FIT_501/PV").value
print "MFT:",mft
print "FIT:",fit

Curr_Month_Flow = mft + fit
print Curr_Month_Flow

```

What does it print if you do this or do you get an error?

---

<div class="post-metadata">

**Author:** ![kade.castille](https://avatars.discourse-cdn.com/v4/letter/k/f05b48/32.png) [@kade.castille](https://forum.inductiveautomation.com/u/kade.castille)\
**Post date:** [November 4, 2020, 8:37pm UTC](https://forum.inductiveautomation.com/t/writing-to-tag-values-on-a-gateway-timer-script-ignition-v7-9-6/40309/11 "2020-11-04T20:37:00Z")

</div>

It worked fine in the console, so I somewhat replicated what you just suggested and we finally got it working. Thanks a lot for your help!
