|
Description
When you extend an event script in a descendent object, the compiler automatically generates a local variable calledAncestorReturnValue that you can use if you need to know the return value of the ancestor event script. The variable is also generated if you override the ancestor script and use the CALL syntax to call the ancestor event script.
Purpose
You can now get the return value of an ancestor event script without explicitly calling the ancestor script, passing it the appropriate arguments and capturing its return value in a local variable.
Migration note
The compiler generates the AncestorReturnValue variable automatically when a script is compiled that extends an event or that calls its ancestor event using the CALL syntax. If a script already has a local variable named AncestorReturnValue, you will see a compiler error the first time the script is compiled, which may be when you migrate an application to PowerBuilder 6.0. To avoid name conflicts, you should rename the local variable.
Usage
Sometimes you want to perform some processing in an event in a descendent object, but that processing depends on the return value of the ancestor event script. You can use a local variable called AncestorReturnValue that is automatically declared and assigned the value of the ancestor event.
The first time the compiler encounters a CALL statement that calls the ancestor event of a script, the compiler implicitly generates code that declares the AncestorReturnValue variable and assigns to it the return value of the ancestor event. If you override the ancestor event script, you have to insert the CALL statement explicitly; if you extend the ancestor event script, the CALL statement is generated by the PowerScript painter.
The data type of the AncestorReturnValue variable is always the same as the data type defined for the return value of the event. The arguments passed to the call come from the arguments that are passed to the event in the descendent object.
Extending and overriding event scripts
|