# Increment Memory Tag using Script

**URL:** <https://forum.inductiveautomation.com/t/increment-memory-tag-using-script/6380>\
**Category:** Ignition\
**Created:** [May 3, 2013, 4:08pm UTC](https://forum.inductiveautomation.com/t/increment-memory-tag-using-script/6380 "2013-05-03T16:08:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stuntman](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@Stuntman](https://forum.inductiveautomation.com/u/Stuntman)\
**Post date:** [May 3, 2013, 4:08pm UTC](https://forum.inductiveautomation.com/t/increment-memory-tag-using-script/6380/1 "2013-05-03T16:08:35Z")

</div>

I have created a memory tag named “Line1Counter” which is an Int4, I want to increment the value of this tag by 1 every second. Once the tag is greater than 29999 I want to reset it back to 0.

I setup a gateway timer script for 1000ms but I am having trouble with the actual script itself.

I have  
Count = system.tag.read(“Line1Counter”)  
Count = Count + 1  
system.tag.write(“Line1Counter”,Count)

I get the error  
Traceback (most recent call last):

File “”, line 2, in

TypeError: unsupported operand type(s) for +: ‘com.inductiveautomation.ignition.common.sqltags.BasicTagValue’ and ‘int’

---

<div class="post-metadata">

**Author:** ![CPowell](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@CPowell](https://forum.inductiveautomation.com/u/CPowell)\
**Post date:** [May 3, 2013, 4:33pm UTC](https://forum.inductiveautomation.com/t/increment-memory-tag-using-script/6380/2 "2013-05-03T16:33:54Z")

</div>

Need to call the value of the tag.

```auto
Count = system.tag.read("Line1Counter")
if Count.value < 30000:
	New_Count = Count.value + 1
	system.tag.write("Line1Counter",New_Count)
else:
	New_Count = 0
	system.tag.write("Line1Counter",New_Count)
```

Cheers,  
Chris

---

<div class="post-metadata">

**Author:** ![Stuntman](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@Stuntman](https://forum.inductiveautomation.com/u/Stuntman)\
**Post date:** [May 3, 2013, 8:08pm UTC](https://forum.inductiveautomation.com/t/increment-memory-tag-using-script/6380/3 "2013-05-03T20:08:24Z")

</div>

So i needed to add the .value field to the script.  
Thanks for the if else statement to.
