Call object handle
- Last Updated: October 16, 2024
- 3 minute read
- OpenEdge
- Version 12.8
- Documentation
A handle to a call object allows you to do the following dynamically:
- Invoke an external procedure, internal procedure, or user-defined function
- Invoke a Windows DLL routine or Unix shared library routine
- Get or set an attribute on a handle-based object, such as a buffer or socket
- Run a method on a handle-based object
Syntax
|
- call-object-handle
- The handle to a call object.
- attribute
- An attribute of the call object.
- method
- A method of the call object. The methods let you set parameters, reset attributes to their default values, and invoke the call object.
Attributes
Methods
| CLEAR( ) method (Call Object Handle) | INVOKE( ) method (Handle) |
| SET-PARAMETER( ) method (Handle) | – |
Examples
The 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:
|
As an alternative to setting the PERSISTENT
attribute, a procedure can be run persistently by setting the PROCEDURE-TYPE
to "PERSISTENT". Regardless of which attribute
is used, the other will automatically be set.
The following fragment dynamically invokes an external procedure as single-run, then dynamically invokes one of its internal procedures:
|
The previous fragment could also be used to
dynamically invoke an external procedure as singleton by changing
PROCEDURE-TYPE to "SINGLETON".
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 or widget: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:
- The number of parameters and their data type is only known at run time
- The routine exists in both a Windows DLL and a Unix shared library
- The routine has a variable number of parameters
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 use widget:attribute or widget:method syntax—and avoid the call object altogether.
- To invoke an internal or
external procedure whose calling sequence (number of parameters
and the data type of each) is unknown at compile time.
- To create a call object, use the following syntax:
CREATE object-handle [ IN widget-pool ]For example:
CREATE CALL hCall.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:
DELETE OBJECT handle.For example:
DELETE OBJECT hCall.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
DELETE OBJECThandle syntax explicitly. - Setting the PROCEDURE-TYPE attribute to "
PERSISTENT" will automatically set the PERSISTENT attribute to TRUE. Likewise, setting the PERSISTENT attribute to TRUE will automatically set PROCEDURE-TYPE to "PERSISTENT". Setting the PROCEDURE-TYPE and PERSISTENT attributes to conflicting values, e.g., PERSISTENT as TRUE and PROCEDURE-TYPE as "SINGLE-RUN", will result in a run-time error.