In ABL, you can write generic application code that accesses a class instance where the type of the instance is not known until runtime. This can reduce the amount of code you write. You must, however, anticipate the possible types your code can expect at runtime.

You use the cast() function to transform a Progress.Lang.Object into a particular type at runtime. Once the type has been transformed, you can access any of its public methods or data members. You can call the cast() function on class instances that are created dynamically with dynamic-new or statically with new.

Here is the syntax for the cast() function.

<typed-object-reference> = cast (<object-reference>,<class-name>).

Syntax Element

Description

typed-object-reference

A property, variable, or field in a temp-table of type class-name

object-reference

A property, variable, or field in a temp-table of type Progress.Lang.Object

class-name

The fully qualified class name where the definition of the class is known only at runtime