DYNAMIC-INVOKE function

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 = ] DYNAMIC-INVOKE( {class-type-name | object-reference} 
  , method-name [ , parameter [ , parameter ] ... ] )
return-value
An optional data element that is assigned the return value from the invoked, non-void method. This return value can have any valid ABL or .NET method return type. 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 to INPUT. 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 use INPUT for 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.

Note: The 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.

See also

DYNAMIC-NEW statement, Invoke( ) method (Class), New( ) method, Parameter passing syntax, Progress.Lang.Class class