Need help with incrementing a counter + 1 with a button

Hi there, I am new to ignition and am trying to learn the basics , so I have a button and was trying to make a script that would + 1 to a tag value whenever I clicked on the button

I am not really familiar with python and don’t understand the syntax very well so I was wondering if someone could help me out , I am currently at the selecting [onActionPerformed] Section and the tag in question is named UCMachine1

Something like this should do the trick.

path = "[default]UCMachine1"
value = system.tag.readBlocking(path)[0].value
system.tag.writeBlocking(path, value + 1)

you are awesome, thank you

path = "[default]UCMachine1"
value = system.tag.readBlocking([path])[0].value
system.tag.writeBlocking([path], [value + 1])

you have added unnecessary syntax for multiple tags, but yes that works too.


No unnecessary syntax pff. Even if you write just to one tag you must provide the parameters as list.
Lucky if it keeps working in future releases with your method.

The option to not provide lists is an undocumented feature added recently. I wouldn’t trust it with a ten-foot pole until it is documented.