DYNAMIC-PROPERTY function
- Last Updated: January 18, 2024
- 2 minute read
- OpenEdge
- Version 12.8
- Documentation
Returns the value of a class property. The
function allows you to refer to a class property by providing a
character expression for the property name, along with an object
reference, THIS-OBJECT system reference, or the
name of a class. The compiler supports both ABL user-defined types
and .NET types for the object reference or class name.
At run time, the AVM:
- Determines the actual type of the object reference, if present
- Resolves the property name expression
- Validates the property data type against the type of the target and performs the assignment
Note: The
DYNAMIC-PROPERTY function
also works with .NET indexed properties. Normally, ABL allows you
to refer to a .NET indexed property without using the property name,
but for dynamic access you must use the property name, typically Item indexed
property.Syntax
|
- return-value
- Specifies a data element that is assigned the value returned when you
execute the property's
GETaccessor. The AVM does the required conversions automatically as if there were a CAST or an ABL conversion function such as STRING or INTEGER present. - object-reference
- Specifies a reference to an ABL or .NET class instance that exposes the specified property as an instance member. The compiler allows object-reference to be declared as any object type. At run time, the object type must resolve to the type that exposes the property.
- class-type-name
- Specifies the name of an ABL or .NET class type that defines the specified property as a static member. This is a CHARACTER expression that the AVM evaluates to the type name of a class at run time. It must only be the name of a class: interfaces are not valid.
- property-name
- Specifies a CHARACTER expression that evaluates to the property name
at run time. Note: The function generates a run-time error if the property-name does not name a property exposed by the object-reference or a static property exposed by class-type-name. A run-time error also gets generated when the required property accessor is not accessible or does not exist. For example, an error is generated when there is an attempt to get the value of a protected property outside the class hierarchy where it is defined, or there is an attempt by the AVM to set a property that has no SET accessor.
- index
- Specifies an integer expression for the index of the specified element. Use index to set or retrieve an individual array element. You can also operate on an entire array by removing the index the same way as you work with non-dynamic property access.
See also
Assignment (=) statement, GetPropertyValue( ) method, SetPropertyValue( ) method