Return values from ancestor scripts
If 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 return 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.
The datatype of the AncestorReturnValue variable
is always the same as the datatype 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 event scripts
The AncestorReturnValue variable is always
available in extended event scripts. When you extend an event script,
PowerBuilder generates the following syntax and inserts it at the
beginning of the event script:
1 |
CALL SUPER::<span>event_name</span> |
You see the statement only if you export the syntax of the
object.
Overriding event scripts
The AncestorReturnValue variable is available
only when you override an event script after you call the ancestor
event using the CALL syntax explicitly:
1 |
CALL SUPER::<span>event_name</span> |
1 |
CALL <span>ancestor_name</span>::<span>event_name</span> |
The compiler does not differentiate between the keyword SUPER and
the name of the ancestor. The keyword is replaced with the name
of the ancestor before the script is compiled.
The AncestorReturnValue variable is declared
and a value assigned only when you use the CALL event
syntax. It is not declared if you use the new event syntax:
1 |
<span>ancestor_name</span>::EVENT <span>event_name</span> ( ) |
Example
You can put code like the following in an extended event script:
1 |
IF AncestorReturnValue = 1 THEN<br>  // execute some code<br>ELSE<br>  // execute some other code<br>END IF |
You can use the same code in a script that overrides its ancestor
event script, but you must insert a CALL statement
before you use the AncestorReturnValue variable:
1 |
// execute code that does some preliminary processing<br>CALL SUPER::ue_myevent<br>IF AncestorReturnValue = 1 THEN<br>... |