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

Step 2: Define the classes and functions in the extension – PB Docs 126 – PowerBuilder Library

Step 2: Define the classes and functions in the extension – PB Docs 126

Step 2: Define the classes and functions in the extension

Your
C++ code must expose two standard methods that
enable PowerBuilder to recognize each native class and create instances
of the class. One of these methods is PBX_GetDescription.

Use PBX_GetDescription to pass
the descriptions of classes and global functions in the PowerBuilder
extension to PowerBuilder. Every extension must export this method.
Importing the PBX or DLL file into a PBL converts the description
of the extension into PowerScript and adds it to the PBL as source
code. The keyword native in the source code indicates
that the PowerBuilder type was defined in an extension.

All the classes or global functions in an extension module
are passed in a single description. The examples that follow illustrate
how you define classes and functions in a description. For the full
syntax, see PBX_GetDescription.

Describing nonvisual classes

Nonvisual
classes can inherit from the NonVisualObject PowerBuilder system class
or any of its descendants. While a native class can inherit from
a user–defined user object, SAP recommends that you use
only system classes. Each native class can provide several functions,
subroutines, and events.

The following example
shows how you use the PBX_GetDescription method
in the C++ code for an extension that includes
three nonvisual classes. ClassName1 inherits
from NonVisualObject, ClassName2 inherits from Exception,
and ClassName3 inherits from Transaction. All
three classes must be in a single description passed by PBX_GetDescription:

Describing visual classes

Visual native
classes can inherit only from the UserObject PowerBuilder system
class. The PowerBuilder VM considers any class that inherits from UserObject
to be a visual class. All other native classes are considered to
be nonvisual classes. For more information about how to describe
visual classes, see “Creating and using a visual
extension”
.

Describing global functions

An extension can include
global functions as well as classes. This example shows a description
for two global functions:

The syntax and usage of global functions defined in an extension
are the same as for global functions defined in the Function painter
in PowerBuilder.

note.png Global functions cannot be overloaded

Like global functions in PowerScript, global functions in
a PowerBuilder extension cannot be overloaded.

Using forward declarations

PowerBuilder extensions can provide
multiple classes. A class can reference any class that is defined earlier in
the description, but if it references a class defined later in
the description, you must provide a forward declaration. This example
shows a description that includes forward declarations for two classes, nativeclass_1 and nativeclass_2,
that reference each other. This example also demonstrates that a
single description can include global functions as well as classes:


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