DYNAMIC-INVOKE function
- Last Updated: November 26, 2024
- 2 minute read
- OpenEdge
- Version 12.2
- Documentation
Invokes a class-based method whose name is specified by a run-time expression, but whose parameters are defined at compile time.
Syntax
|
- return-value
- An optional data element that is assigned the return value from the invoked, non-void method. The AVM checks return-value at run time for data type compatibility with what is actually returned by the method. ABL raises a run-time error if you invoke a void method where a return value is expected.
- class-type-name
- The name of an ABL or .NET class type that defines the specified method as a static member. If the method is static, this parameter is a CHARACTER expression that the AVM evaluates to the type name of the class at run time. This expression must specify a class type name as described in the Type-name syntax reference entry, except that you must always specify the complete type name; any present USING statement has no effect.You cannot use class-type-name to call an instance method. For more information on specifying class type names, see the Type-name syntax reference entry.
- object-reference
- Specifies a reference to an ABL or .NET class instance that defines the specified method as an instance member. You cannot use object-reference to call a static method. For information on specifying object references, see the reference entry for a Class-based object reference.
- method-name
- A CHARACTER expression that evaluates to the method name. The AVM evaluates method-name at run time.
- [ , parameter [ , parameter ]... ]
- Specifies zero or more parameters passed to the method. You must
provide the parameters identified by the specified method, matched with respect to
number, data type, and mode. To invoke a method that is overloaded in the class, you
must specify sufficient information for each parameter in order to disambiguate methods that have similar parameter
lists. Otherwise, the AVM raises an error identifying the ambiguity.
If the parameter mode (
INPUT,OUTPUT,INPUT-OUTPUT) is not specified, the mode defaults toINPUT. This differs from normal invocation of a method, where the parameter mode defaults to the method parameter. In this case, the compiler does not know the method at compile time, and therefore must useINPUTfor the default, instead of inferring it from the called method. We recommended that you always supply the parameter mode.For more information on parameter passing syntax and on disambiguating overloaded ABL and .NET methods, see the Parameter passing syntax reference entry.
Invoke() method of the Progress.Lang.Class class
provides similar functionality to the DYNAMIC-INVOKE function. The
advantage to the latter is that it has a fixed, compile-time parameter list and does not
require the creation of a ParameterList object at run time.Example
MyObject is a class that has one method called
MultiplyTheValue. This method is invoked in the code that follows.
| MyObject.cls |
|---|
|
In this example, the MultiplyTheValue
method in the class instance referenced by rObj expects a
DECIMAL value.
|
See also
DYNAMIC-NEW statement, Invoke( ) method (Class), New( ) method, Parameter passing syntax, Progress.Lang.Class class