# Need help with incrementing a counter + 1 with a button

**URL:** <https://forum.inductiveautomation.com/t/need-help-with-incrementing-a-counter-1-with-a-button/55509>\
**Category:** Ignition\
**Created:** [January 28, 2022, 9:49pm UTC](https://forum.inductiveautomation.com/t/need-help-with-incrementing-a-counter-1-with-a-button/55509 "2022-01-28T21:49:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![IgnitionNewbie](https://avatars.discourse-cdn.com/v4/letter/i/94ad74/32.png) [@IgnitionNewbie](https://forum.inductiveautomation.com/u/IgnitionNewbie)\
**Post date:** [January 28, 2022, 9:49pm UTC](https://forum.inductiveautomation.com/t/need-help-with-incrementing-a-counter-1-with-a-button/55509/1 "2022-01-28T21:49:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [January 28, 2022, 9:56pm UTC](https://forum.inductiveautomation.com/t/need-help-with-incrementing-a-counter-1-with-a-button/55509/2 "2022-01-28T21:56:21Z")

</div>

Something like this should do the trick.

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

```

---

<div class="post-metadata">

**Author:** ![IgnitionNewbie](https://avatars.discourse-cdn.com/v4/letter/i/94ad74/32.png) [@IgnitionNewbie](https://forum.inductiveautomation.com/u/IgnitionNewbie)\
**Post date:** [January 28, 2022, 10:35pm UTC](https://forum.inductiveautomation.com/t/need-help-with-incrementing-a-counter-1-with-a-button/55509/3 "2022-01-28T22:35:32Z")

</div>

you are awesome, thank you

---

<div class="post-metadata">

**Author:** ![jespinmartin1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jespinmartin1/32/57175_2.png) [@jespinmartin1](https://forum.inductiveautomation.com/u/jespinmartin1)\
**Post date:** [January 29, 2022, 4:13am UTC](https://forum.inductiveautomation.com/t/need-help-with-incrementing-a-counter-1-with-a-button/55509/4 "2022-01-29T04:13:41Z")

</div>

> [@josborn](#):
>
> ```auto
> path = "[default]UCMachine1"
> value = system.tag.readBlocking(path)[0].value
> system.tag.writeBlocking(path, value + 1)
> 
> ```

- 

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

```

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [January 29, 2022, 6:57am UTC](https://forum.inductiveautomation.com/t/need-help-with-incrementing-a-counter-1-with-a-button/55509/5 "2022-01-29T06:57:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jespinmartin1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jespinmartin1/32/57175_2.png) [@jespinmartin1](https://forum.inductiveautomation.com/u/jespinmartin1)\
**Post date:** [February 27, 2022, 3:31am UTC](https://forum.inductiveautomation.com/t/need-help-with-incrementing-a-counter-1-with-a-button/55509/6 "2022-02-27T03:31:16Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/f/bfdd27e972b940438b189e95457978e0dec193f2.png)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 27, 2022, 3:47am UTC](https://forum.inductiveautomation.com/t/need-help-with-incrementing-a-counter-1-with-a-button/55509/7 "2022-02-27T03:47:25Z")

</div>

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.
