Call object handle
A handle to a call object allows you to do the following dynamically:
Syntax
call-object-handle
attribute
method
Attributes
Methods
ExamplesThe following fragment dynamically invokes an external procedure non-persistently:
The following fragment dynamically invokes an external procedure persistently, then dynamically invokes one of its internal procedures:
The following fragment uses a single call object handle multiple times:
The following fragment gets an attribute:
The following fragment sets an attribute:
The following fragment drives the call object’s INVOKE( ) method from a TEMP-TABLE:
The following fragment implements an ABL function,
sleep
, which causes the AVM to sleep for a specified number of milliseconds:
Note that the code checks to determine on which OS it is running, and invokes the appropriate Windows DLL or UNIX shared library.
Notes
- Invoking logic dynamically requires many more lines of code and is less efficient than invoking it statically. You typically use the call object when you cannot use the RUN statement, the DYNAMIC-FUNCTION() function, or
widget:attribute
orwidget:method
syntax, as in the following situations:
- To invoke an internal or external procedure whose calling sequence (number of parameters and the data type of each) is unknown at compile time.
Note: If only the name of the procedure is unknown at compile time, use the RUN statement with the VALUE option—and avoid the call object altogether.- To invoke a function whose calling sequence is unknown at compile time.
Note: If only the name of the function is unknown at compile time, use the DYNAMIC-FUNCTION() function—and avoid the call object altogether.- To reference a widget attribute or method whose name is unknown at compile time.
- To invoke a Windows DLL routine or Unix shared library routine when:
If you already know the name of the attribute or procedure, you know its syntax, since the name implies certain syntax. And if you know the syntax, you know the calling sequence, since the syntax defines the calling sequence. And if you know the calling sequence, you can usewidget:attribute
orwidget:method
syntax—and avoid the call object altogether.- To create a call object, use the following syntax:
For example:
Note: Unlike most ABL objects, the call object, by default, goes into the SESSION widget pool, not into the closest unnamed widget pool.- To delete a call object, use the following syntax:
For example:
Since the call object, by default, goes into the SESSION widget pool, not into the closest unnamed widget pool, to delete a call object created when the IN widget-pool option is not used, use the DELETEobject
handle
syntax explicitly.See also
OpenEdge Release 10.2B
|