# Memory Tag to count from 1 to 1200 when the action button clicked

**URL:** <https://forum.inductiveautomation.com/t/memory-tag-to-count-from-1-to-1200-when-the-action-button-clicked/91462>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [June 6, 2024, 6:07am UTC](https://forum.inductiveautomation.com/t/memory-tag-to-count-from-1-to-1200-when-the-action-button-clicked/91462 "2024-06-06T06:07:15Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![srinivasan\_s](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@srinivasan\_s](https://forum.inductiveautomation.com/u/srinivasan_s)\
**Post date:** [June 6, 2024, 6:07am UTC](https://forum.inductiveautomation.com/t/memory-tag-to-count-from-1-to-1200-when-the-action-button-clicked/91462/1 "2024-06-06T06:07:15Z")

</div>

I want the memory tag to count from 1 to 1200 when the one button is clicked in View A. This memory tag will be binded to label component in View B.  
I tried to execute this in memory tag, but not working,

```python
counter = system.tag.readBlocking(["[~]counter_tag"])

	counter = counter + 1

	system.tag.writeBlocking(["[default]My/Tag/counter"],["counter"])

```

 ![Counter](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/7/37ebe12b4e1238bc69362755aaec159058f2894f.png)

---

<div class="post-metadata">

**Author:** ![Hayden\_Watson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/hayden_watson/32/48792_2.png) [@Hayden\_Watson](https://forum.inductiveautomation.com/u/Hayden_Watson)\
**Post date:** [June 6, 2024, 6:33am UTC](https://forum.inductiveautomation.com/t/memory-tag-to-count-from-1-to-1200-when-the-action-button-clicked/91462/2 "2024-06-06T06:33:06Z")

</div>

Read blocking will return a list of tag objects, to get the value of the first (and only) tag you should

```python
counter = system.tag.readBlocking(["[~]counter_tag"])[0].value

if counter >= 1200:
     counter = 1
else:
     counter += 1

system.tag.writeBlocking(["[default]My/Tag/counter"],[counter])

```

You also seem to be writing a string as the value, and not the variable `counter`

---

<div class="post-metadata">

**Author:** ![srinivasan\_s](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@srinivasan\_s](https://forum.inductiveautomation.com/u/srinivasan_s)\
**Post date:** [June 6, 2024, 6:37am UTC](https://forum.inductiveautomation.com/t/memory-tag-to-count-from-1-to-1200-when-the-action-button-clicked/91462/3 "2024-06-06T06:37:42Z")

</div>

Thank you for your reply. Need a clarity how it will update continuously when I click one button in View A.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [June 6, 2024, 6:47am UTC](https://forum.inductiveautomation.com/t/memory-tag-to-count-from-1-to-1200-when-the-action-button-clicked/91462/4 "2024-06-06T06:47:10Z")

</div>

A computer can count from 1 to 1200 EXTREMELY fast... It's likely you won't see anything but 1200.

Do you want to count 1200 seconds?

Do you want this to be on a per-client basis? i.e. each client can have a different timer?

If global, you want to set the datetime you press the button in a memory tag, then in an expression memory tag, use the expression:

```python
if(isNull({date/tag}), -1, secondsBetween({date/tag}, now(1000))) // these might be the wrong way around, I always swap them...

```

To stop it, use an on value change event on the counter tag to set the date tag value to None if its value is \> 1200. If you want it to reset after 1200 that is.

If you want it client based, I'd use sessions props to do the same thing

---

<div class="post-metadata">

**Author:** ![srinivasan\_s](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@srinivasan\_s](https://forum.inductiveautomation.com/u/srinivasan_s)\
**Post date:** [June 6, 2024, 8:42am UTC](https://forum.inductiveautomation.com/t/memory-tag-to-count-from-1-to-1200-when-the-action-button-clicked/91462/5 "2024-06-06T08:42:38Z")

</div>

Thankyou for your reply. Will workout and update

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [June 6, 2024, 9:04am UTC](https://forum.inductiveautomation.com/t/memory-tag-to-count-from-1-to-1200-when-the-action-button-clicked/91462/6 "2024-06-06T09:04:33Z")

</div>

This and your other timer questions should really be handled by the PLC. I think you are building a fragile system that will break.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [June 6, 2024, 11:10pm UTC](https://forum.inductiveautomation.com/t/memory-tag-to-count-from-1-to-1200-when-the-action-button-clicked/91462/7 "2024-06-06T23:10:55Z")

</div>

I didn't see the other timer questions, but if this is for control, certainly what @Transistor says is a must. SCADA is _ **not** _ for process control logic
