PropertyChange Event script

i have an Event script that is not quite working out for me and hoping to get some help.
it is a propertyChange script like this:
if event.propertyName == “HS_RETURN”:
if event.source.HS_RETURN == 1:
value = 0
event.source.HS_OUT = value
event.source.HS_RETURN = value

i have towo dynamc properties defined, HS_OUT and HS_RETURN, both are bound to plc Tags. When HS_RETURN changes from a 0 to a 1, i want to clear both bits. The script triggers and executes properly both properties being cleared, however, only the tag bound to HS_OUT gets cleared, the tag bound to HS_RETURN stays set even though the actual property is 0. Both tags are configured with ReadWrite access rights and both properties are set to allow bi-directional.
Any Thoughts?
Thanks,
Scott

You would need to be looking at the Event.NewValue if you are using the “property.change” event (casing may be incorrect for event.newvalue as I’m working from memory :blush: )
I also think it may need to be set as an “invoke later” type script if you are wanting to change the value that is changing…

Hope this helps a bit.

Thanks,
i think you may be on to something with the invokeLater thing.
I have never defined a function before though and seem to be having difficulty with the syntax.
Can you help me out?
How do i turn my little script shown in my original post into a function that can be called with the invokeLater call?
Thanks again.

Never having tried this before I finally got the following to work with 2 DB tags. The following is from a Gateway Tag Change script whose Tag Path is tagchangetest1 :

value = newValue.value
if value == 1:
def reset():
import system
value = 0
system.tag.writeToTag(“tagchangetest2”, value )
system.tag.writeToTag(“tagchangetest1”, value )
reset()

If I set tagchangetest2 to ON and then do the same to tagchangetest1 both tags go OFF. Tried the invokelater and could not get to work.
Have no idea if this helps but thought I’d give it a go :laughing:
edit: It appears the tabs disappear on the forum so you need to add these.

[quote=“Brett Yeomans”]
edit: It appears the tabs disappear on the forum so you need to add these.[/quote]
If you wrap it in a [ code][ /code] it should put it in. :thumb_right:

value = newValue.value if value == 1: def reset(): import system value = 0 system.tag.writeToTag("tagchangetest2", value ) system.tag.writeToTag("tagchangetest1", value ) reset()