Using
cascaded calling and return values
PowerBuilder dot notation allows you to chain together several
object function or event calls. The return value of the function or
event becomes the object for the following call.
This syntax shows the relationship between the return values of
three cascaded function calls:
|
1 |
func1returnsobject( ).func2returnsobject( ).func3returnsanything( ) |
Disadvantage of cascaded calls
When you call several functions in a cascade, you cannot check
their return values and make sure they succeeded. If you want to check
return values (and checking is always a good idea), call each function
separately and assign the return values to variables. Then you can use
the verified variables in dot notation before the final function
name.
Dynamic calls
If you use the DYNAMIC keyword in a chain of cascaded calls, it
carries over to all function calls that follow.
In this example, both func1 and func2 are called
dynamically:
|
1 |
object1.DYNAMIC func1().func2() |
The compiler reports an error if you use DYNAMIC more than once in
a cascaded call. This example would cause an error:
|
1 |
object1.DYNAMIC func1().DYNAMIC func2() // error |
Posted functions and
events
Posted functions and events do not return a value to the calling
scripts. Therefore, you can only use POST for the last function or event
in a cascaded call. Calls before the last must return a valid object
that can be used by the following call.
System events
System events can only be last in a cascaded list of calls,
because their return value is a long (or they have no return value).
They do not return an object that can be used by the next call.
An event you have defined can have a return value whose datatype
is an object. You can include such events in a cascaded call.