Define an object reference field in a temp-table
- Last Updated: April 26, 2024
- 1 minute read
- OpenEdge
- Version 12.2
- Documentation
You can define temp-table fields as the class type,
Progress.Lang.Object, the built-in class that is the
implicit super class (root class) of all other classes in ABL. This allows a temp-table
field to hold object references of any class type. When object references are assigned to
the field, they are implicitly cast to the root class, Progress.Lang.Object. When you want to use the object reference as a specific
object type, you must cast the object reference to the specific type. For more information
on casting, see Object reference assignment and casting.
This is the syntax to define a class field in a temp-table:
Syntax
|
Element description for this syntax diagram follow:
- field-name
- The name of a field defined as the ABL root class.
The following example defines a temp-table field to
hold a class instance, by defining the field as Progress.Lang.Object. In this case, the purpose is to store different ShapeClass instances in order to calculate an area on each
ShapeClass object in sequence, according to its subclass
type (RectangleClass or CircleClass), as shown:
|
This previous example is a modified version of the Main class used to demonstrate polymorphism (see Use polymorphism with classes). This version of the Main class shows how you might use temp-table fields to support
polymorphic object references and use the CAST function to
cast down to the common functionality of the polymorphic super class (ShapeClass).