Calling assembly methods from PowerScript

When you call methods from managed assemblies in PowerScript, you must use PowerBuilder datatypes in any method arguments or return values. Table 13-3 shows the mappings between .NET, C#, and PowerBuilder datatypes.

Table 13-3: Datatype mappings in managed assembly methods

.NET datatype

C# datatype

PowerBuilder datatype

System.Boolean

boolean

Boolean

System.Byte

Byte

Byte

System.Sbyte

Sbyte

Sbyte

System.Int16

short

Int

System.UInt16

ushort

Uint

System.Int32

int

Long

System.UInt32

uint

Ulong

System.Int64

long

Longlong

System.UInt64

ulong

Unsignedlonglong

System.Single

float

Real

System.Double

Double

Double

System.Decimal

Decimal

Decimal

System.Char

Char

Char

System.String

String

String

System.DateTime

System.Datetime

Datetime

For example, suppose you want to reference a method foo with arguments that require separate int and long datatype values when you call the method in C# script. The class containing this method is defined in an assembly in the following manner:

public class MyClass
{
 public int foo(int a, long b);
  {
    return a + b
  }
}

In PowerScript code, you must replace the foo method datatypes with their PowerBuilder datatype equivalents (long for int, longlong for long):

long p1, returnValue
longlong p2
#IF Defined PBWINFORM Then
    MyClass instanceOfMyClass
    instanceOfMyClass = create MyClass    
    returnValue = instanceOfMyClass.foo(p1, p2)
#END IF

NoteUnidirectional cross-language calls Although you can call .NET methods in PowerScript, you cannot currently call PowerBuilder functions from .NET methods. Some PowerBuilder datatypes such as Blob, Date, and Time do not have equivalent datatypes in the C# language. Because you cannot make calls to PowerBuilder functions, there is no need to map these PowerBuilder datatypes to C# datatypes.