Property Change Script not firing?

This is an offshoot of my previous thread, but I started a new one as I think this relates to the property change more than the scripting itself.

I have a Numeric text field with integer bound to a tag with the hour of day.

The script checks for the hour and does a reset of other variables at 5:00am.

“if event.source.intValue == 5”

It works every time in designer, but I’ve had the live version miss sometimes. Oddly, if I save when it misses, then it fires right away. So suspect I did something that Property Change doesn’t like rather than an issue in the if statement. I did consider it firing so fast that using it’s own intValue in the if statement was a bad idea - but then I’d expected it to be off by an hour rather than missing. Stranger: why it always fires in designer; I even tested it firing on every hour a couple different days, and it worked all day.

Thank you!

Property change scripts on Vision Windows only fire if the vision window is open in a client or in the designer with the “play” button active. You probably want the script either directly on the tag (valueChanged) or (better) as a gateway tag change script. If multiple instances of the window are open, the script will run multiple times.

2 Likes

Can you post the whole script?

Assuming the variables you need to reset are tags, and the reset is setting to zero, this should work. You would need to use your tag provider and path.

if newValue.getValue()  = 5:
	tags = system.tag.browseTags(parentPath="[TagProvider]Variables")
	tagDS = []
	for tag in tags:
		tagDS.append(str(tag.fullPath))
	system.tag.writeBlocking(tagDS, [0] * len(tagDS))
1 Like

That would explain some things. Oddly, I have a near identical Property Change script that seems to always work. But that one doesn’t need to fire in the middle of the night, so perhaps the page is open frequently enough somewhere for it to work - as well as sometimes even catch this one.

Neither one would be adversely affected by multiple firing, so I’d not noticed anything on that extreme.

Thank you!

Variables, custom properties, and text fields, no tags being written. But the logic should be the same, regardless.

Thank you!