Creating hot links
Some OLE servers support property change notifications. This
means that when a property is about to be changed and again after
it has been changed, the server notifies the client, passing information
about the change. These messages trigger the events PropertyRequestEdit
and PropertyChanged.
PropertyRequestEdit event
When a property is about to change, PowerBuilder triggers
the PropertyRequestEdit event. In that event’s script you
can:
-
Find out the name of the property
being changed by looking at the PropertyName argument. -
Obtain the old property value and save it
The property still has its old value, so you can use the standard
syntax to access the value. -
Cancel the change by changing the value of the CancelChange
argument to TRUE
PropertyChanged event
When a property has changed, PowerBuilder triggers the PropertyChanged event.
In that event’s script, you can:
-
Find out the name of the property being changed by looking
at the PropertyName argument -
Obtain the new property value
The value has already changed, so you cannot cancel
the change.
Using the PropertyName argument
Because the PropertyName argument is a string, you cannot use
it in dot notation to get the value of the property:
1 |
value = This.Object.PropertyName // Will not work |
Instead, use CHOOSE CASE or IF statements
for the property names that need special handling.
For example, in the PropertyChanged event, this code checks
for three specific properties and gets their new value when they
are the property that changed. The value is assigned to a variable
of the appropriate datatype:
1 |
integer li_index, li_minvalue<br>long ll_color<br> <br>CHOOSE CASE Lower(PropertyName)<br>   CASE "value"<br>   li_index = ole_1.Object.Value<br>   CASE "minvalue"<br>   li_minvalue = ole_1.Object.MinValue<br>   CASE "backgroundcolor"<br>   ll_color = ole_1.Object.BackgroundColor<br>   CASE ELSE<br>   ... // Other processing<br>END CHOOSE |
If a larger change occurred
In some cases the value of the PropertyName argument is an
empty string (“”). This means a more general change has occurred—for
example, a change that affects several properties.
If notification is not supported
If the OLE server does not support property change notification,
then the PropertyRequestEdit and PropertyChanged events are never
triggered, and scripts you write for them will not run. Check your
OLE server documentation to see if notification is supported.
If notifications are not supported and your application needs
to know about a new property value, you might write your own function
that checks the property periodically.
For more information about the PropertyRequestEdit
and PropertyChanged events, see the PowerScript Reference.