This lesson is part of the Scripting in Ignition course. You can browse the rest of the lessons below.

LESSON LIST

Autoplay Off
Take topic challenge

LESSON

Property Change Scripts

Description

Learn how to use Property Change scripts to configure behavior on component properties.

Video recorded using: Ignition 8.0

Transcript

(open in window)

[00:00] Oftentimes, it may be useful to trigger a script based on a particular property change event. Perspective makes it really easy to add scripts to these particular events. To add a property change script to a particular property, you simply need to find the component that you want to add a property change script to, and then find the property that you want to add the property change script to. Right-click on that property, and in the popup menu, go down to Add Change Script. In Perspective, you have the ability to add these property change scripts to any property on any component. In here, we can write a script using the full power of the Python scripting language, as well as any of the arguments that are provided here for us. One thing to keep in mind is that the arguments for previousValue and currentValue are qualified value objects. As qualified values, they have a value quality and a time stamp, so if you're just looking for the value, then you need to make sure you call something like currentValue.value. Let's take a look at this property change script in action. I have here a simple view with a label and a text field, and on the text field's text property, I've placed a property change script. You can see to the right of the property, it's got this little icon that indicates that a property change script is present on the property. If we take a look at the property change script here, you can see that it's just a very simple script that simply writes the current value of the text field to the text property of the label component. I'll go ahead and hit OK, save my changes, and open up my Perspective session. When I enter in new text into the text field, the property change script fires immediately after every change, and writes to the label accordingly.

You are editing this transcript.

Make any corrections to improve this transcript. We'll review any changes before posting them.