Access a class instance dynamically
- Last Updated: January 16, 2024
- 1 minute read
- OpenEdge
- Version 12.8
- Documentation
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 |
| A property, variable, or field in a temp-table of type class-name |
| A property, variable, or field in a temp-table of type
|
| The fully qualified class name where the definition of the class is known only at runtime |