Property Change Component Scripting

Hello everyone,

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:

if event.propertyName in ("visible", "value"):
2 Likes

I wanted to be able to check for both properties, and see if both conditions are met. Is this even possible?

If not I tried the visible property itself and it worked:

if event.propertyName=="visible" :
    system.tag.writeBlocking("[default]tag.value", event.source.visible)

But when I want to check only for the value, it is not working:

if event.propertyName=="value" :
   if event.source.value==2 :
        system.tag.writeBlocking("[default]tag.value", 1)

Please explain what action you are trying to respond to, and what you want to happen to other things when that action happens.

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.

Where do the visibility and value come from?

the visibility and the value are coming from an expression that is indirectly related to the database

Should the tag be kept up to date when no client is open? (Is the tag driving behavior in your machine/process?)

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.

1 Like