# Tag event scripts value changed

**URL:** <https://forum.inductiveautomation.com/t/tag-event-scripts-value-changed/70815>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [March 9, 2023, 8:22am UTC](https://forum.inductiveautomation.com/t/tag-event-scripts-value-changed/70815 "2023-03-09T08:22:32Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![qiang\_chen](https://avatars.discourse-cdn.com/v4/letter/q/e274bd/32.png) [@qiang\_chen](https://forum.inductiveautomation.com/u/qiang_chen)\
**Post date:** [March 9, 2023, 8:22am UTC](https://forum.inductiveautomation.com/t/tag-event-scripts-value-changed/70815/1 "2023-03-09T08:22:32Z")

</div>

Hello:  
I have 100 tags, tag1-tag100, how can I assign them in batches (tag event scripts/value changed)  
like this :  
for i in range(1,101):  
system.tag.writeBlocking(["tagi"],10)  
i = i +1

#Then the value of tag1-tag100 will be equal to 10

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [March 9, 2023, 9:25am UTC](https://forum.inductiveautomation.com/t/tag-event-scripts-value-changed/70815/2 "2023-03-09T09:25:43Z")

</div>

> [@qiang\_chen](#):
>
> for i in range(1,101):  
> system.tag.writeBlocking(["tagi"],10)  
> i = i +1

Welcome!

```auto
for i in range(1,101):
   system.tag.writeBlocking(["tag"+str(i)],10)
   i = i +1

```

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [March 9, 2023, 10:17am UTC](https://forum.inductiveautomation.com/t/tag-event-scripts-value-changed/70815/3 "2023-03-09T10:17:24Z")

</div>

> [@qiang\_chen](#):
>
> i = i +1

There is no need for the `i = i + 1` The i will automatically be incremented by the `for loop`.

...but if there were a need for something like `i = i + 1` , it would probably be more pythony to write it:  
`i += 1`

---

<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:** [March 9, 2023, 10:28am UTC](https://forum.inductiveautomation.com/t/tag-event-scripts-value-changed/70815/4 "2023-03-09T10:28:54Z")

</div>

If you actually want to write all 100 tags to 10 though, you should not write them one by one as this is _incredibly_ inefficient and slow. Write them all at once with:

```auto
ints = range(1, 101)
system.tag.writeBlocking(["tag{}".format(i) for i in ints] , [10]*len(ints))

```

---

<div class="post-metadata">

**Author:** ![qiang\_chen](https://avatars.discourse-cdn.com/v4/letter/q/e274bd/32.png) [@qiang\_chen](https://forum.inductiveautomation.com/u/qiang_chen)\
**Post date:** [March 10, 2023, 1:25am UTC](https://forum.inductiveautomation.com/t/tag-event-scripts-value-changed/70815/5 "2023-03-10T01:25:24Z")

</div>

Hello,Thank you for your reply,This assignment function is working,I want this 100 tags to add 10 per hour,like this:  
for i in range(1,101):  
Vi= system.tag.readBlocking(["tag" + str(i)])[0].value  
Vi =Vi +10  
system.tag.writeBlocking(["tag" + str(i)],Vi)  
What should i do?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 10, 2023, 1:33am UTC](https://forum.inductiveautomation.com/t/tag-event-scripts-value-changed/70815/6 "2023-03-10T01:33:26Z")

</div>

I question the utility overall of 100 tags updating in lockstep, but...

```python
count = 100
paths = ["tag{}".format(i + 1) for i in xrange(count)]
currentValues = [qv.value for qv in system.tag.readBlocking(paths)]
newValues = [currentValue + 10 for currentValue in currentValues]

system.tag.writeBlocking(paths, newValues)

```

---

<div class="post-metadata">

**Author:** ![qiang\_chen](https://avatars.discourse-cdn.com/v4/letter/q/e274bd/32.png) [@qiang\_chen](https://forum.inductiveautomation.com/u/qiang_chen)\
**Post date:** [March 10, 2023, 1:59am UTC](https://forum.inductiveautomation.com/t/tag-event-scripts-value-changed/70815/7 "2023-03-10T01:59:31Z")

</div>

Thank you for your reply,it's work.  
The reason why I need 100 tags here is that I have 100 data to save to the database. I do it through tag history, which may be a bit stupid. Do you have any simple method?

---

<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:** [March 10, 2023, 4:38am UTC](https://forum.inductiveautomation.com/t/tag-event-scripts-value-changed/70815/8 "2023-03-10T04:38:24Z")

</div>

Create a dedicated SQL table and write your values into that. It'll be far easier to query from that way as well
