Derived Tag Incrementing Memory Tag Value

Hi all,

I’m new to Ignition so hoping to get some assistance with something that seems like it should be possible. I’m experimenting with a Derived Tag. I would like to compare the value of two tags, if they do not meet my requirements I would like to increment the value of a memory tag.

Could someone point me in the right direction?

Thank you in advance!

You can use a gateway timer script.
In that script, compare the values of the two tags using and if they are not within your requirments, increment your memory tag using system.tag.write.

1 Like

Thanks for the reply! I had tried using a Tag Event Script but I it wouldn’t update the tag. Checking the log, it would give a valueChanged NameError: and say the tag doesn’t exist.

I created an expression tag and it would update itself correctly, but this is where I had the Tag Event Script and it didn’t work.

I’ll try the gate timer script to see if I can make headway with hit. I liked the idea of the tag though.

This isn’t what I’m wanting, but its an example of it not working.

If the tag Counter has a timestamp older than tag Current_Sheet, I would like to have the value to match the tag Counter.

var0 =“Counter”).value
var1 =“Counter”).timestamp
var2 =“Current_Sheet”).timestamp
if var1 > var2:
system.tag.write(“Current_Sheet”, var0)

Make sure that you specify the provider when targeting tags from the gateway scope, e.g. [default]MyTag instead of MyTag.

Hope this helps…


Thank you, I’ll try that now!

From the Script Console I can enter the following and it works but not from a Gateway Tag Script. I tried the square brackets but it wouldn’t work in either window.

var1 =‘SizingSaw/Counter’)
var2 =‘SizingSaw/Current_Sheet’)

if var1 <> var2:
system.tag.write(‘SizingSaw/Current_Sheet.value’, var1.value)

Finally, I was able to get it to work using a Tag Event Script. I didn’t change anything so not sure what’s wrong but I’m happy.


Gateway-scoped scripts need fully-qualified paths; they don’t know what realtime tag provider to execute reads/writes against. So"SizingSaw/Counter") would become"[default]SizingSaw/Counter") in a gateway script.


Hola que tal puedes, pasar el codigo de la solucion.

I hope it is okay that I am bringing back a question from 2017

I am using version 8.1 while trying to count an event. I can assign values to the tag. I can’t seem to get it to increment itself though.

system.tag.write("[.]New Tag", “[.]New Tag”+1)

did not work inside a valuechanged script in a tag


tempvariable=("[.]New Tag"+1)
system.tag.write("[.]New Tag", tempvariable)

This did not work


for some reason

system.tag.write("[.]New Tag", tempvariable)

This one worked, and assigned the value to 7

This isn't an expression, that syntax for reading the value doesn't do anything. You're trying to write a String value with '1' concatenated to the end of it.

If you want to increment the value of a tag read the value first using system.tag.readBlocking before you increment and write it again.

Can you give me an example line of code that will write a tag to value of itself plus 1?

The tag event scripting tutorial used strings.

I put this in a button’s actionPerformed event:

qv = system.tag.readBlocking(["Test"])[0]

new_v = qv.value + 1

system.tag.writeBlocking(["Test"], [new_v])
1 Like

qv = system.tag.readBlocking([“Test”])[0]

new_v = qv.value + 1

system.tag.writeBlocking([“Test”], [new_v])

When I look at this:
I am understanding that the qv variable begins to exist in the first line.
The system.tag.readBlocking is reading the value of the tag called Test.
The brackets that are square differentiate the value of the tag vs it being a string?
I am totally confused by the
on the end of the first line.

Second line, why is .value used?
not work?

I don’t have questions about the last line.

Thanks for helping me.
I program in a few languages, and it seems to be hindering me haha

Because readBlocking accepts a list of tag paths and returns a list of QualifiedValues, corresponding in length and position with those tag paths.

This is because of what I mentioned above about it returning a list of QualifiedValue, which is an object with value, timestamp, and quality components. You need to get the value out of it to actually increment.

temp = system.tag.readBlocking(["[.]New Tag"],[0])
system.tag.writeBlocking(["[.]New Tag"],[tempvariable],[0])
system.tag.writeBlocking(["[.]New Tag2"],6)

I have written this.
It does not change the values of either New Tag or New Tag2.
When I designate the tag, I click on the tag icon, then find the tag to insert.
is automatically written as part of the tag.

I noticed your code did not have [.]
I noticed in other versions, code reads like [Default]“Tag” rather than [.]“Tag”
Is that part wrong in my code?

I looked at both links, and tried a few ways to fix my code. I am still trying things till I hear back too.
Thank you for helping me. If there is any training I might have missed, I will review it.
I am watching the videos too to see if I missed it.

temp = system.tag.readBlocking(["[.]New Tag.value"],[0])
system.tag.writeBlocking(["[.]New Tag.value"],[tempvariable],[0])
system.tag.writeBlocking(["[.]New Tag2.value"],6)

This attempt also did not work, if it helps to spot the part I am misunderstanding.

Actually just found out I can spot errors in the diagnostic tab when I doubleclick the tag.

Should be

temp = system.tag.readBlocking(["[.]New Tag"])[0]
tempvariable = temp.value + 1
system.tag.writeBlocking(["[.]New Tag","[.]New Tag2"],[tempvariable,6])

The [.] is shorthand that means the path is Realative to the folder of the Tag that is being bound.

That did not work for me either.

Sorry, had a typo, the code has been edited.