I have this weird issue where Im running a onAction script on a button. I pull 4 binary tags into the code via system.tag.readBlocking("blah blah tag") but when i try to use it in a if statement the code seemingly doesn't work not errors just a flag int i have embedded in code gets to the point where its used.
My work around is assign the tag to a custom prop in the button and then reference this in the code "self.custom.tag" and then the rest of the code executes as expected. Has anyone had this before?
tag = system.tag.readBlocking('[PLC]Test/Tags/Tag')
value = self.getSibling("Table").props.selection.data.name
faultInt = 0
if value == "John Smith" and not tag:
faultInt = 10
No matter the conditions i return 10. If i change the "tag" reference to be the custom one as described it all works as intended.
edit* Formatted code for readability as suggested by nminchin.
system.tag.readBlocking returns a list of QualifiedValue, not a basic type. To read a tag value from the results, for example the first tagpath, you need to use something like:
PS you've also missed an end quote
PPS. if you want to read multiple tags' values, the simplest way is to use:
tagN) = [qval.value for qval in system.tag.readBlocking([
PPPS. Use to format code, otherwise it's unreadable
Also, to diagnose things like this, you can always start by (reading the user manual) printing the type() of the object to the console. You can then see what it is compared to what you expect it to be.