Script in the Tag

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.

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?

system.tag.writeBlocking | Ignition User Manual

# 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

1 Like

It's tempting to put it in a script within the tag, but do it in a Gateway Tag Change script, instead.

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

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


1 Like

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!

1 Like