kghali
March 29, 2021, 5:36pm
1
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"])
kghali
March 29, 2021, 5:42pm
3
Yeah I tried that too and it didn’t work
lrose
March 29, 2021, 6:05pm
4
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
kghali
March 29, 2021, 6:19pm
6
Thank you all. It worked!