I have a label component and its visibility status, as well as value, is bound to two different scripts.
Now, I am trying to update a boolean tag to be 1 or true when two conditions are met in the program:
I wrote this:
if event.propertyName=="visible" and event.propertyName=="value":
if event.source.value==2 and evenet.source.visible==1:
system.tag.writeBlocking("[default]tag.value", event.source.visible)
But it is not working. I tried different scripts but none of them working. I would appreciate any suggestion. Thank you!
Events arrive separately. You won’t ever have the propertyName equal to two different names at the same time. Did you mean to use or instead of and ? If so, you can also use a shorter expression like so:
So I want to write value 1 to a Boolean tag when a numeric label component is visible in my screen and also has a value of non zero (!=0).
I wanted to check for both conditions (visibility and non zero value) at the same time. But if that is not possible. I wanted to check for the value itself.
So for this application, the operator scans a barcode, and then the database returns the row associated with that barcode and then every single label/component gets its value from that row, this is how that works. SO basically the change in barcode derives the process.
I do not understand why this should work:
if event.propertyName=="visible" :
system.tag.writeBlocking("[default]tag.value", event.source.visible)
but this one does not:
if event.propertyName=="value" :
if event.source.value!=0 :
system.tag.writeBlocking("[default]tag.value", 1)
So the event that matters is the property that is receiving the data from the database. Monitor that property for change, perform your custom logic there, and write the tag in that event script. Don’t try to recombine the results from that data’s arrival.