To use enumerations that you import from a .NET assembly, you must surround the enumeration references in a conditional compilation block that is valid for your .NET target environment.
You must also append an exclamation mark (“!”) to each of the enumeration’s constant strings that you declare in the conditional code block.
Public enum TimeOfDay
{
Morning = 0,
AfterNoon,
Evening
}
#if defined PBDOTNET THEN
ns_1.ns_2.TimeOfDay a
a=ns_1.ns_2.TimeOfDay.Morning!
#end if
enumerationType.enumerationEntryName!
namespacename.enumerationType.enumerationEntryName!
If there is no enumerationType enumeration class prefacing the declaration of a constant in a .NET conditional code block, PowerBuilder assumes the enumeration is a system-defined type and returns an error if the system-defined type is not found.
[enumerationType.]enumerationEntryName!Although you cannot use dot notation in a constant declaration for a system-defined enumeration in standard PowerScript, the pb2cs compiler must let you use dot notation for constant declarations that you make in a conditional compilation block for the .NET environment. Prefixing a constant declaration in the .NET environment with a PowerBuilder system enumeration name is equivalent to making the same declaration without a prefix.
The VM initially checks whether the enumerationType is a declared .NET enumeration class. If it does not find the enumeration class, it checks whether the enumerationType is a PowerBuilder system enumeration. When the enumerationType matches the name of a PowerBuilder system enumeration, the VM sets the constant for your .NET application or component.
Therefore, for the system Alignment enumeration, the constant declaration Alignment.Left! produces the same result as the Left! declaration inside a .NET conditional code block. Outside such a code block, the Alignment.Left! declaration causes a compiler error.