Interacting with the COM component
Invoking component methods
Once a connection to a COM component has been established,
the client application can begin using the component methods.

You must use the REF keyword when you call a method on a COM
object that has an output parameter. For example: of_add( arg1, arg2, REF sum )
Example
Using the EmpObj object created in the
previous example, this example calls two methods on the component,
then disconnects and destroys the instance:
1 |
Long units, time<br>Double avg, ld_retn<br>String ls_retn<br> <br>ld_retn = EmpObj.f_calcdayavg(units, time, REF avg) <br>ls_retn = EmpObj.f_teststring()<br> <br>EmpObj.DisconnectObject()<br>DESTROY EmpObj |
Passing result sets
PowerBuilder provides three system objects to handle getting
result sets from components running in transaction server environments
and returning result sets from PowerBuilder user objects running
as transaction server components. These system objects (ResultSet,
ResultSets, and ADOResultSet) are designed to simplify the conversion
of transaction server result sets to and from DataStore objects
and do not contain any state information.
Handling runtime errors
Runtime error information from custom class user objects executing
as OLE automation objects, COM objects, or COM+ components
is reported to the container holding the object as exceptions (or,
for automation objects, as exceptions or facility errors). Calls
to the PowerBuilder SignalError function are
also reported to the container. To handle runtime errors generated
by PowerBuilder objects, code the ExternalException event of the
OLE client.
For more information about handling runtime errors in OLE
or COM objects, see “Handling errors”.