Increment Memory Tag using Script

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’

Need to call the value of the tag.

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

1 Like

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