Three methods

There are three ways to access PowerBuilder user objects. You can access:

A user object as automation server

You can define a class user object and register it in the registry. When you use your client’s functions for accessing an external object, you have access to the user object’s properties and functions. (Automation accesses the object’s instance variables as properties.)

The advantages of a registered user object as an automation server include:

Figure 20-2: Interaction of class user object as server with client

The example shows a client application and a P B D or D L L that contains a library with a class user object employed as a server. OLE automation commands and returned data flow between the class user object as server and the client application.

For you to access an independent user object, it must be installed as an independent entity in the registry. You connect to it by means of an OLEObject variable and use automation to access it. The object invokes a PowerBuilder runtime session to support it.

When you access the object in your runtime session, you create a single instance of the object, and PowerBuilder invokes a runtime session to support it. For each registered object you create, you incur the overhead of additional runtime sessions.

The steps you take to register and use a user object are described in “Using a user object as an automation server”.

PowerBuilder as automation server

When you install PowerBuilder, an entry is added to the registry for PowerBuilder.Application, a general-purpose PowerBuilder automation server. You can create instances of any number of class user objects and access their properties and methods. (Automation accesses the object’s instance variables as properties.)

The advantages of using PowerBuilder.Application include:

When you connect to PowerBuilder.Application, you specify the libraries that you will access. You can instantiate any number of user objects whose definitions reside in those libraries, as well as system classes.

Each object you create in the client exists as an independent OLEObject in the client, and you can address each one using automation. If the client passes a server object reference back to another server object in the same runtime session, PowerBuilder recognizes the PowerBuilder datatype of the object. This allows the two objects to interact in the server session, rather than being limited to automation commands from the client.

Figure 20-3: Objects interacting in a server session

The example shows a client application and the Power Builder dot Application server, which has access to multiple libraries containing class user objects. OLE automation commands and returned data flow between Power Builder dot Application and the client application.

The steps you take to set up and use PowerBuilder.Application are described in “Using PowerBuilder as an automation server”.

Named automation server

For business reasons, you might want to avoid references to PowerBuilder.Application, but still have access to the additional functionality it provides—for example, the efficiency of instantiating more than one object in a server session.

You can create an entry in the registry that serves as a second pointer to PowerBuilder.Application, allowing you to give the server a name appropriate for your business.

The steps involved in setting up a named server are described in “Creating and using a named server”.