Datatype Mappings

When you call methods from managed assemblies in PowerScript, you must use PowerBuilder datatypes in any method arguments or return values.

This table shows the mappings between .NET, C#, and PowerBuilder datatypes:

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

Calling PowerScript methods from .NET assemblies

If you generate a .NET assembly or Web service from a PowerBuilder target, the generated methods can be called by a different .NET assembly or application, but these calls must be made using .NET syntax and datatypes. In the table for Datatype mappings in managed assembly methods, the datatype mapping is bidirectional, so you can call methods on the .NET assemblies you generate from PowerBuilder using the .NET equivalents for PowerScript datatypes shown in the table.

Some PowerScript datatypes do not have a one-to-one correspondence with datatypes in .NET. When you generate a .NET assembly or Web service from PowerBuilder, PowerBuilder converts these datatypes as shown in the following table. If you call methods using these datatypes from a .NET application, you must substitute the .NET datatype equivalents shown in this table:

Mappings for PowerScript datatypes unsupported in .NET

PowerBuilder datatype

C# datatype

.NET datatype

Blob

Byte [ ]

System.Byte [ ]

Date

System.Datetime

System.Datetime

Time

System.Datetime

System.Datetime