Openedge Abl Dynamic Call Objects
Openedge Abl Dynamic Call Objects
Applications
Copyright
© 2020 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.
®
These materials and all Progress software products are copyrighted and all rights are reserved by Progress
Software Corporation. The information in these materials is subject to change without notice, and Progress
Software Corporation assumes no responsibility for any errors that may appear therein. The references in
these materials to specific platforms supported are subject to change.
Corticon, DataDirect (and design), DataDirect Cloud, DataDirect Connect, DataDirect Connect64, DataDirect
XML Converters, DataDirect XQuery, DataRPM, Defrag This, Deliver More Than Expected, Icenium, Ipswitch,
iMacros, Kendo UI, Kinvey, MessageWay, MOVEit, NativeChat, NativeScript, OpenEdge, Powered by Progress,
Progress, Progress Software Developers Network, SequeLink, Sitefinity (and Design), Sitefinity, SpeedScript,
Stylus Studio, TeamPulse, Telerik, Telerik (and Design), Test Studio, WebSpeed, WhatsConfigured,
WhatsConnected, WhatsUp, and WS_FTP are registered trademarks of Progress Software Corporation or one
of its affiliates or subsidiaries in the U.S. and/or other countries. Analytics360, AppServer, BusinessEdge,
DataDirect Autonomous REST Connector, DataDirect Spy, SupportLink, DevCraft, Fiddler, iMail, JustAssembly,
JustDecompile, JustMock, NativeScript Sidekick, OpenAccess, ProDataSet, Progress Results, Progress
Software, ProVision, PSE Pro, SmartBrowser, SmartComponent, SmartDataBrowser, SmartDataObjects,
SmartDataView, SmartDialog, SmartFolder, SmartFrame, SmartObjects, SmartPanel, SmartQuery, SmartViewer,
SmartWindow, and WebClient are trademarks or service marks of Progress Software Corporation and/or its
subsidiaries or affiliates in the U.S. and other countries. Java is a registered trademark of Oracle and/or its
affiliates. Any other marks contained herein may be trademarks of their respective owners.
March 2020
Updated: 2020/09/10
OpenEdge Web Paper: Use Dynamic Call Objects in ABL Applications: Version 12.2 3
Copyright
4 OpenEdge Web Paper: Use Dynamic Call Objects in ABL Applications: Version 12.2
Contents
Table of Contents
Code examples.............................................................................................17
Run an internal procedure of a persistent external procedure.............................................................18
Run an internal procedure of a single-run or singleton procedure.......................................................19
Use a call object multiple times............................................................................................................19
Get an attribute.....................................................................................................................................20
Set an attribute.....................................................................................................................................21
Multiple dynamic invokes from a temp-table.........................................................................................21
Invoke a Windows DLL routine.............................................................................................................22
Implement a sleep timer.......................................................................................................................23
OpenEdge Web Paper: Use Dynamic Call Objects in ABL Applications: Version 12.2 5
Contents
6 OpenEdge Web Paper: Use Dynamic Call Objects in ABL Applications: Version 12.2
Preface
Purpose
This set of topics describes how to:
• Dynamically execute a procedure
• Execute a user-defined function
• Get or set a handle attribute
• Invoke a handle method
• Invoke a Windows Dynamic Link Library (DLL) routine or invoke a UNIX shared library routine using the
call object handle
Note: In the context of this set of topics, method refers to a built-in, handle-based ABL method, such as
qryhandle:GET-NEXT( ). You cannot run a class-based method using this feature. You can, however,
dynamically invoke a class-based method using the DYNAMIC-INVOKE function or the Invoke( ) method
of the Progress.Lang.Class class. For more information, see the ABL Reference.
Audience
These topics are intended for all ABL developers.
Organization
The following sections are included:
• ABL elements related to the call object on page 9
• When to use the call object on page 15
• Code examples on page 17
OpenEdge Web Paper: Use Dynamic Call Objects in ABL Applications: Version 12.2 7
Preface
Documentation conventions
See Documentation Conventions for an explanation of the terminology, format, and typographical conventions
used throughout the OpenEdge content library.
Purpose
This set of topics describes how to:
• Dynamically execute a procedure
• Execute a user-defined function
• Get or set a handle attribute
• Invoke a handle method
• Invoke a Windows Dynamic Link Library (DLL) routine or invoke a UNIX shared library routine using the
call object handle
Note: In the context of this set of topics, method refers to a built-in, handle-based ABL method, such as
qryhandle:GET-NEXT( ). You cannot run a class-based method using this feature. You can, however,
dynamically invoke a class-based method using the DYNAMIC-INVOKE function or the Invoke( ) method
of the Progress.Lang.Class class. For more information, see the ABL Reference.
Audience
These topics are intended for all ABL developers.
Organization
The following sections are included:
• ABL elements related to the call object on page 9
• When to use the call object on page 15
• Code examples on page 17
Documentation conventions
See Documentation Conventions for an explanation of the terminology, format, and typographical conventions
used throughout the OpenEdge content library.
8 OpenEdge Web Paper: Use Dynamic Call Objects in ABL Applications: Version 12.2
1
ABL elements related to the call object
The ABL elements related to the call object consist of a statement, a handle, attributes, and methods.
Note: For more information on these ABL elements, see ABL Reference.
The CREATE CALL statement creates a call object, then stores a handle to it in the handle variable you specify.
A call object handle lets you do the following dynamically:
OpenEdge Web Paper: Use Dynamic Call Objects in ABL Applications: Version 12.2 9
Chapter 1: ABL elements related to the call object
10 OpenEdge Web Paper: Use Dynamic Call Objects in ABL Applications: Version 12.2
Attributes of a call object handle
1
See Run an internal procedure of a persistent external procedure on page 18 for details on how the PERSISTENT and
PROCEDURE-TYPE attributes interact.
OpenEdge Web Paper: Use Dynamic Call Objects in ABL Applications: Version 12.2 11
Chapter 1: ABL elements related to the call object
12 OpenEdge Web Paper: Use Dynamic Call Objects in ABL Applications: Version 12.2
Methods of a call object handle
OpenEdge Web Paper: Use Dynamic Call Objects in ABL Applications: Version 12.2 13
Chapter 1: ABL elements related to the call object
14 OpenEdge Web Paper: Use Dynamic Call Objects in ABL Applications: Version 12.2
2
When to use the call object
For some use cases, programming with the call object requires more lines of code than other ABL alternatives.
The following table shows an example of the code required to invoke an external procedure dynamically and
statically.
hCall:INVOKE( ).
/* Clean up */
DELETE OBJECT hCall.
As the previous table illustrates, executing hello.p dynamically using the call object requires many more
lines of code and is therefore less efficient than doing it with static invoke.
Consider using the call object for these situations:
OpenEdge Web Paper: Use Dynamic Call Objects in ABL Applications: Version 12.2 15
Chapter 2: When to use the call object
• 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 the only the name of the procedure is unknown at compile time, use the RUN statement with the
VALUE option, and avoid using the call object.
Note: If the only the name of the function is unknown at compile time, use the DYNAMIC-FUNCTION( )
function, and avoid using the call object.
• To dynamically invoke a Windows DLL routine or a UNIX shared library routine when the following is true:
• 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
16 OpenEdge Web Paper: Use Dynamic Call Objects in ABL Applications: Version 12.2
3
Code examples
The next set of topics contain code examples showing some ways in which the call object can be used.
• Get an attribute
• Set an attribute
OpenEdge Web Paper: Use Dynamic Call Objects in ABL Applications: Version 12.2 17
Chapter 3: Code examples
hCall:INVOKE.
/* Clean up */
DELETE PROCEDURE hCall:IN-HANDLE.
DELETE OBJECT hCall.
When persis.p is invoked dynamically, the handle of the running persistent procedure is stored automatically
in the call object's IN-HANDLE attribute. When internal-persis-proc is invoked dynamically, ABL knows
it resides in the running persistent procedure whose handle is stored in the call object's IN-HANDLE attribute.
You can also run a procedure persistently by setting the PROCEDURE-TYPE attribute to "PERSISTENT". Setting
the PROCEDURE-TYPE attribute to "PERSISTENT" and setting the PERSISTENT attribute to "TRUE" are equivalent,
and setting one will automatically set the other. Setting the two attributes to conflicting values, e.g.,
PROCEDURE-TYPE to "SINGLETON" and PERSISTENT to TRUE, will cause a run-time error.
18 OpenEdge Web Paper: Use Dynamic Call Objects in ABL Applications: Version 12.2
Run an internal procedure of a single-run or singleton procedure
hCall:INVOKE.
ASSIGN
hCall:CALL-NAME = "internal-single-proc"
/* Sets CALL-TYPE to the default */
hCall:CALL-TYPE = PROCEDURE-CALL-TYPE
hCall:NUM-PARAMETERS = 1.
/* Clean up */
DELETE PROCEDURE hCall:IN-HANDLE.
DELETE OBJECT hCall.
OpenEdge Web Paper: Use Dynamic Call Objects in ABL Applications: Version 12.2 19
Chapter 3: Code examples
hCall:INVOKE.
/* Clean up */
DELETE PROCEDURE hCall:IN-HANDLE.
DELETE OBJECT hCall.
This example resets the call object handle by using the CLEAR( ) method between invoking hello.p (the
first invoke) and invoking persis.p (the second invoke).
Get an attribute
This example gets the current value of the TITLE attribute of a frame. The call object's CALL-TYPE attribute
is set to GET-ATTR-CALL-TYPE. The value of the TITLE attribute is returned through the call object's
RETURN-VALUE attribute, as shown:
ASSIGN
hCall:IN-HANDLE = myframe_handle
hCaLL:CALL-TYPE = GET-ATTR-CALL-TYPE
hCall:CALL-NAME = "TITLE".
hCall:INVOKE( ).
Mytitle = hCall:RETURN-VALUE.
20 OpenEdge Web Paper: Use Dynamic Call Objects in ABL Applications: Version 12.2
Set an attribute
Set an attribute
This example sets the SESSION handle's NUMERIC-FORMAT attribute to "european":
ASSIGN
hCall:IN-HANDLE = "session"
hCall:CALL-TYPE = SET-ATTR-CALL-TYPE
hCall:CALL-NAME = "numeric-format"
hCall:NUM-PARAMETERS = 1.
In contrast to the Get an attribute on page 20 example, this "Setting an attribute" example:
ASSIGN
hDtypes = ttParam:BUFFER-FIELD("datatypes")
hIOmodes = ttParam:BUFFER-FIELD("iOmodes").
ttParam:FIND-FIRST.
OpenEdge Web Paper: Use Dynamic Call Objects in ABL Applications: Version 12.2 21
Chapter 3: Code examples
hCall:CALL-NAME = ttParam:BUFFER-FIELD("run-name"):BUFFER-VALUE
hCall:NUM-PARAMETERS = ttParam:BUFFER-FIELD("nparms"):BUFFER-VALUE.
FOR ix = 1 TO hCall:NUM-PARAMETERS:
hCall:SET-PARAMETER(ix, hDtypes:BUFFER-VALUE(ix),
hIOmodes:BUFFER-VALUE(ix), ttParam:BUFFER-FIELD(ix):BUFFER-VALUE).
END.
hCall:INVOKE( ).
DELETE OBJECT hCall.
hCall:INVOKE( ).
cValue = hCall:RETURN-VALUE.
22 OpenEdge Web Paper: Use Dynamic Call Objects in ABL Applications: Version 12.2
Implement a sleep timer
Note that the code determines on which OS it is running, and invokes the appropriate Windows DLL or UNIX
shared library.
OpenEdge Web Paper: Use Dynamic Call Objects in ABL Applications: Version 12.2 23
Chapter 3: Code examples
24 OpenEdge Web Paper: Use Dynamic Call Objects in ABL Applications: Version 12.2