Syntax 1 For creating an object instance on a remote server
Description
Creates an instance of a component running on EAServer. This function can be used
to instantiate a remote object from a PowerBuilder client. In addition,
it can be used within a component running on EAServer to instantiate another component
running on a different server.
Controls
Connection objects
Syntax
|
1 |
<span>connection</span>.<span>CreateInstance</span> (<span>objectvariable</span> {, <span>classname</span> } ) |
|
Argument |
Description |
|---|---|
|
connection |
The name of the Connection object used |
|
objectvariable |
A global, instance, or local variable |
|
classname (optional) |
A string whose value is the name of the |
Return Values
Long. Returns 0 if it succeeds and one of the following values
if an error occurs:
-
50 Distributed
service error -
52 Distributed communications error
-
53 Requested server not active
-
54 Server not accepting requests
-
55 Request terminated abnormally
-
56 Response to request incomplete
-
57 Not connected
-
62 Server busy
Usage
Before calling CreateInstance, you need
to connect to a server. To do this, you need to call the ConnectToServer function.
CreateInstance allows you to create an
object on a remote server. If you want to create an object locally,
you need to use the CREATE statement.
When you deploy a remote object’s class definition
in a client application, the definition on the client has the same
name as the remote object definition deployed in the server application.
Variables declared with this type are able to hold a reference to
a local object or a remote object. Therefore, at execution time
you can instantiate the object locally (with the CREATE statement)
or remotely (with the CreateInstance function)
depending on your application requirements. In either case, once
you have created the object, its physical location is transparent
to client-side scripts that use the object.
Examples
The following statements create an object locally
or remotely depending on the outcome of a test. The statements use
the CreateInstance function to create a remote
object and the CREATE statement to create a local
object:
|
1 |
boolean bWantRemote |
|
1 |
connection myconnect |
|
1 |
uo_customer iuo_customer |
|
1 |
|
1 |
//Determine whether you want a remote |
|
1 |
//object or a local object. |
|
1 |
... |
|
1 |
//Then create the object. |
|
1 |
IF bWantRemote THEN |
|
1 |
//Create a remote object |
|
1 |
IF myconnect.<span>CreateInstance</span>(iuo_customer) <> 0 THEN |
|
1 |
//deal with the error |
|
1 |
... |
|
1 |
END IF |
|
1 |
ELSE |
|
1 |
//Create a local object |
|
1 |
iuo_customer = CREATE uo_customer |
|
1 |
END IF |
|
1 |
|
1 |
//Call a function of the object. |
|
1 |
//The function call is the same whether the object was |
|
1 |
//created on the server or the client. |
|
1 |
IF isValid(iou_customer) THEN |
|
1 |
iuo_customer.GetCustomerData() |
|
1 |
END IF |