# Script in the Tag

**URL:** <https://forum.inductiveautomation.com/t/script-in-the-tag/108519>\
**Category:** Ignition\
**Tags:** scripting, ignition81\
**Created:** [July 15, 2025, 7:10pm UTC](https://forum.inductiveautomation.com/t/script-in-the-tag/108519 "2025-07-15T19:10:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gustavo.chamorro](https://avatars.discourse-cdn.com/v4/letter/g/eb8c5e/32.png) [@gustavo.chamorro](https://forum.inductiveautomation.com/u/gustavo.chamorro)\
**Post date:** [July 15, 2025, 7:10pm UTC](https://forum.inductiveautomation.com/t/script-in-the-tag/108519/1 "2025-07-15T19:10:47Z")

</div>

Hi,  
I receive via mqtt a large string with the value of my tags and I'm separating it by ";" so I made a script to separate the values of this string.

```python
tag_path = ("[MQTT Engine]texto")  
tag_value = system.tag.read(tag_path).value.split("; ")

print tag_value [2]

```

Up to this point, we're OK, it's working properly and I can see it from the console output. My question is how can I take this value that comes out of my script and assign it to a Tag?

---

<div class="post-metadata">

**Author:** ![dillon](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dillon/32/81537_2.png) [@dillon](https://forum.inductiveautomation.com/u/dillon)\
**Post date:** [July 15, 2025, 7:14pm UTC](https://forum.inductiveautomation.com/t/script-in-the-tag/108519/2 "2025-07-15T19:14:05Z")

</div>

[system.tag.writeBlocking | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-tag/system-tag-writeBlocking)

```python
# Create a list with the tag paths to be updated.
paths = ["[default]Folder/Tag_A","[default]Folder/Tag_B"]
 
# Create a list with the update values, one value for each path.
values = [1,2]
 
# Execute the write operation.
system.tag.writeBlocking(paths, values)

```

Unless you want to do it Asynchronously:

[system.tag.writeAsync | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-tag/system-tag-writeAsync)

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [July 15, 2025, 7:19pm UTC](https://forum.inductiveautomation.com/t/script-in-the-tag/108519/3 "2025-07-15T19:19:41Z")

</div>

It's tempting to put it in a script within the tag, but do it in a [Gateway Tag Change script,](https://www.docs.inductiveautomation.com/docs/8.1/platform/scripting/scripting-in-ignition/gateway-event-scripts#tag-change-scripts) instead.

```python
tag_value = event.currentValue.value.split('; ')

system.tag.writeAsync(['[default]path/to/my/tag'], [tag_value[2]])

```

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/8/58ed27f850f0e9635497fcd3ad0046fec5301409.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/4/e4763fb854d59f7355c5a99486dd953d8bb94ef7.png)

---

<div class="post-metadata">

**Author:** ![gustavo.chamorro](https://avatars.discourse-cdn.com/v4/letter/g/eb8c5e/32.png) [@gustavo.chamorro](https://forum.inductiveautomation.com/u/gustavo.chamorro)\
**Post date:** [July 16, 2025, 12:31pm UTC](https://forum.inductiveautomation.com/t/script-in-the-tag/108519/4 "2025-07-16T12:31:14Z")

</div>

Thanks guys!

With the (system.tag.writeAsync or writeBlocking) I managed to write in my tags, in the Gateway tag change script I had to make changes, but I managed to leave it even better than I thought. Thanks a lot guys!

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/4/d45ec78034b4c02d120c32bf19cf7706a2be2cc2.png)
