Connection Information

To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host.

Connection Type

Using a user object as an automation server – PB Docs 90 – PowerBuilder Library

Using a user object as an automation server – PB Docs 90

Using a user object as an automation server

Accessing a registered user object as an automation server
involves these steps:

  1. Create the object you will access.
  2. Build the object’s runtime library.
  3. Register the object.
  4. Write code in the client that connects to and uses
    the object.

Creating a class user object to be a server

How you define user objects for an automation server depends
mainly on your application design. The object must be a custom class
user object. You define instance variables and functions for the
object. The object can declare and instantiate other objects for
its own use.

note.gif No references to visual objects The class user object you use as an automation server cannot
contain any references to visual objects such as message boxes or
windows.

Objects on the client

You can pass your object references to other objects in the
client application. Those references are of type OLEObject, and
your object can use automation syntax to access properties and methods
of the object. (Automation accesses the object’s instance
variables as properties.)

Testing the user object

Before you try accessing your user object as a server, test
its design and functions in a simpler environment. You can build
an application for testing the user object locally.

Building the object’s runtime library

After you have defined your object, use the Library painter
to build a dynamic library (PBD) or compiled
library (DLL). The reasons for choosing either
type (Pcode or compiled machine code) are the same as for building
any PowerBuilder application.

For more information, see “Compiler basics”.

You might want to use the Library painter to reorganize libraries
so that your object and any other objects it instantiates are in
a library by themselves. Otherwise, your library will be bigger
than it needs to be.

Here is a quick overview of what you need to do to build your
library in the Library painter:

  1. In
    the Library painter, select the library name.
  2. Select Library>Build Runtime Library.
  3. Check or clear the Machine Code check box to correspond
    to your decision about PBDs versus DLLs.
    Other options in the dialog box are not essential
    to this process. For information about them, click the Help button
    or see the PowerBuilder User’s Guide
    .
  4. Click OK to build the library.
  5. Move the library to the directory you want it to
    be registered in.

Registering the object

To use your object, you have to register it in the registry.
You can also create a type library that provides information to
registry browser applications about your object’s properties
and functions.

For more information, see “More about user objects
and the registry “
.

The Automation Server project wizard makes registering and
creating type libraries easy.

proc.gif To create registry information and register your
object:

  1. Select the Automation Server wizard from
    the Project tab in the New dialog box.

  2. Complete all the pages in the wizard.

    Use Table 19-1 to
    help you.

    Table 19-1: Automation Server wizard pages
    Page What to specify
    Select component Select the object you want to use as
    an automation server. You can select only one object. For when to
    specify PowerBuilder.Application, see “Creating and using
    a named server “
    .
    Specify Program Identifier Specify an identifier for the object
    such as Mycompany.Myapp. Do not supply a version
    number. PowerBuilder constructs a version-dependent entry using the
    version number you specify on another screen. The identifier can
    contain up to 39 characters, must not contain any punctuation apart
    from the period between vendor and application, and must not start
    with a digit.
    Specify Registry File and Object GUID If the GUID text box is empty, click
    Generate to generate a new globally unique identifier (GUID). The
    new GUID will be the class identifier (CLSID) for your object. If
    you specified an existing programmatic identifier, the GUID will be
    filled in. You can create a new GUID if you do not want to reuse
    the existing one. For information about reusing GUIDs, see “Multiple versions and updates”.

    The registry update file is a text file containing information for
    updating the registry. Typically it has the same name as the library,
    and the extension REG.

    Create Type Library File You need to create a type library only
    if you want OLE browsers to display information about the properties
    and methods of your object.
    Specify Build Options Check the machine code DLL check
    box if you built a DLL instead of a PBD file.
  3. Select File>Open from the menu bar and
    select the project created by the wizard, or double-click the Build
    Project item on the ToDo list.

  4. Select Design>Build Project from the
    menu bar in the Project painter to generate the registry and type
    library files.

  5. Run the registry file to add information to the
    registry.

For more information about the registry and
writing your own registration tool, see “Creating registry
information”
.

Writing client code that accesses the user object

The client code for accessing a registered user object is
simpler than the code for accessing PowerBuilder.Application. The
library list and machine code properties are already determined
and stored in the registry. All you need to do is connect to the
object and use automation to access its properties and methods.

PowerBuilder as client

To establish a server automation session with your user object,
you need code for these steps.

  1. Declare
    an OLEObject variable for your user object:

  2. Connect to your object using its programmatic identifier
    (ProgID) and check that the connection was established. A status
    of 0 indicates success:

  3. Access functions or properties of the object using
    automation syntax:

If you want to handle errors in the OLEObject ExternalException
and Error events, use a user object inherited from OLEObject instead
of declaring an OLEObject variable:

  1. Open the User Object painter
    and create a standard class user object inherited from OLEObject.
  2. Write scripts for the Error and ExternalException
    events.
  3. Use the name of the new class instead of OLEObject
    in the declaration:

Visual Basic as client

Similar code in Visual Basic connects to your registered object.

  1. Declare an object variable for your user object:

  2. Connect to your object using its programmatic identifier
    (ProgID) and check that the connection was established:

  3. Access functions or properties of the object using
    automation syntax:


Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x