Ignition Script Creates Duplicate Messageboxes

So I created a project that is a searchable Photoeye status screen. You type in an asset number and it will give you live feedback of how the photoeye is doing. I want a messagebox to pop up if the user types in the wrong asset number.

This is how I did it and it works great except for the fact that I get two messageboxes whenever the dataquality goes to zero. How do I fix this?

What's happening is that the dataQuality property is being checked for every property that changes in your component, instead of only being checked once when the dataQuality property changes.

To fix it, change your qualifier to this:

if event.propertyName == 'dataQuality' and event.newValue == 0:
3 Likes

Now the messagebox won't show up at all.

Hmmm. What I normally do in this situation is open up a diagnostic console to take a look under the hood.

Change your propertyChange script to this:

print event.propertyName, event.newValue

Make sure there is not a typo in your propertyName, and make sure that the datatype of your value is correct.

For example, if it's an integer, it should be:

event.newValue == 0

If it's a bool:

event.newValue == False

If it's a string:

event.newValue == '0'

etc...

In case you or some future reader doesn't know, the diagnostic console is accessed in this way:
image

The data from the print statements will show up there

It looks like the event.newValue is a bool but when I changed event.newValue to False in the if statement it still wont show the message box. I put a print function inside the if statement and it never showed up in the console which tells me that the if statement is never evaluating to true.

The print statement should be put outside the if. The purpose is to see which property change events are occuring.

Yeah I did that first to confirm but I just put a print statement inside the if to see if the if was ever evaluating to true. It's not unfortunately.

What were the event names, and values that printed to the console?

On the other hand, I should probably mention that I wouldn't use a gui locking popup for this. Perhaps a better approach would be to create a visual indicator like a label or an icon, and simply bind it's visibility property inversely to the data quality property.

1 Like