Reading Tags Not Working

I have 3 tags: Tag1, Tag2, and Tag3
if Tag1 == 1:
Tag2 = Tag3
x = system.tag.readBlocking(“Path to Tag1”)
if x==1:
system.tag.writeBlocking(“Tag2.value path”, currentValue)
else:
system.tag.writeBlocking(“Tag2.value path”, x)

Why isn’t this working?

readBlocking and writeBlocking expect lists.

It would be something like this:

system.tag.readBlocking(["Path to Tag1"])

Yeah I tried that too and it didn’t work

readBlocking also returns a list of qualified values so to get the value you would need something like this:

x = system.tag.readBlocking(['Path To Tag1'])[0].value
1 Like

Edit: Looks like @lrose beat me to it on the qualified value error.

Couple other errors in there.

readBlocking returns a list of qualified values. So you have to pull out the value from the return list and access the value:

x = system.tag.readBlocking(["Path to Tag1"])[0].value

Also, when using writeBlocking you need to give it a list of values instead of a single value:

if x==1:
system.tag.writeBlocking([“Tag2 value path”], [currentValue])
else:
system.tag.writeBlocking([“Tag2 value path”], [x])
2 Likes

Thank you all. It worked!