Methods and datatypes

Functions

Each PowerBuilder COM object supports a single interface that exposes a method for each user-defined public function in the custom class user object.

The function’s return value is represented by an additional retval argument. For example, if an object has these user object functions:

f_addtwo (long al_num1, long al_num2) returns long
f_getinfo (REF string as_name, REF integer ai_age, 
    REF character ac_gender) returns integer

These member functions are generated in the IDL file:

HRESULT f_addtwo( [in] long al_num1, 
    [in] long al_num2, [out, retval] long * retval );
HRESULT f_getinfo( [in, out] BSTR * as_name, 
    [in, out] short * ai_age, [in, out] unsigned
    char * ac_gender, [out, retval] short * retval );

Instance variables

Since COM objects never expose their data, public instance variables in the custom class user object can be represented in the COM object as interface methods for getting and setting the variable value. To specify that variable accessor methods will be exposed in the interface, you can use the Project wizard or the Objects property page in the Project painter.

If the public variable is writable, the put method will be exposed. For private and protected variables and variables declared as privateread or protectedread and privatewrite or protectedwrite, no methods are generated. If the variable is publicly readable, the get method will be exposed. For example, if an object has these instance variables:

public string is_name
private integer ii_a
public privatewrite string is_label 
constant real lr_pi = 3.14159265

These are the methods that are generated in the IDL file:

[id(4), propget] HRESULT is_name([out,retval] 
    BSTR *is_name);
[id(4), propput] HRESULT is_name([in] 
    BSTR is_name);
[id(1), propget] HRESULT is_label([out,retval] 
    BSTR *is_label);
[id(6), propget] HRESULT lr_pi( [out,retval] 
    float * lr_pi);

Datatype mappings

PowerBuilder datatypes map to COM datatypes as shown in Table 27-2.

Table 27-2: PowerBuilder and COM datatype mapping

PowerBuilder datatype

COM datatype (variants)

Boolean

Variant_BOOL

Character

Unsigned char

Integer

Short

UnsignedInteger

Unsigned short

Long

Long

UnsignedLong

Unsigned long

Real

Float

Double

Double

Decimal

Double

String

BSTR

Date

DATE

Time

DATE

DateTime

DATE

Blob

SAFEARRAY (Unsigned char)

Arrays (PowerBuilder datatype)

SAFEARRAY (COM datatype)

ResultSet

LPDISPATCH

Custom class user objects*

LPDISPATCH

Any

Not supported

Global structures

Not supported

OLEObjects

Not supported

*  Custom class user objects must be created within the same client in the same COM apartment (that is, in the same thread)