Try OpenEdge Now
skip to main content
Programming Interfaces
External Program Interfaces : Shared Library and DLL Support : Passing parameters to a shared library routine : Passing arrays as parameters : INTEGER and DECIMAL arrays
 
INTEGER and DECIMAL arrays
When a DLL function requires an array of type BYTE, SHORT, UNSIGNED-SHORT, INT, LONG, FLOAT, or DOUBLE, you can pass an array of the appropriate ABL type (INTEGER or DECIMAL) as a parameter. You can use any parameter mode (INPUT, INPUT-OUTPUT, or OUTPUT). For the data type in the prototype, you can use just the type (for example, LONG) or you can specify it with the HANDLE TO option (for example, HANDLE TO). ABL always passes the array of values as a pointer so the HANDLE TO option is redundant, as it is with any INPUT-OUTPUT or OUTPUT parameter.
Here is an example C Code Prototype for a function called updateCounts:
updateCounts(short * parray);
This example is the equivalent ABL for the updateCounts procedure when accessing the function statically:
DEFINE VARIABLE iCnts AS INTEGER NO-UNDO EXTENT 5.

RUN updateCounts (iCnts).

PROCEDURE updateCounts EXTERNAL "myApp.dll" PERSISTENT:
  DEFINE INPUT-OUTPUT PARAMETER parray AS SHORT.
END.
This example is the equivalent ABL for the updateCounts procedure when accessing the function dynamically:
DEFINE VARIABLE hCall AS HANDLE  NO-UNDO.
DEFINE VARIABLE ix    AS INTEGER NO-UNDO.
DEFINE VARIABLE mCnts AS MEMPTR  NO-UNDO EXTENT 5.

DO ix = 1 TO EXTENT(mCnts):
  SET-SIZE(mCnts[ix]) = 50.
END.

CREATE CALL hCall.
ASSIGN
  hCall:CALL-NAME             = "updateCounts"
  hCall:LIBRARY               = "myApp.dll"
  hCall:CALL-TYPE             = DLL-CALL-TYPE
  hCall:RETURN-VALUE-DLL-TYPE = "INTEGER"
  hCall:PERSISTENT            = TRUE
  hCall:NUM-PARAMETERS        = 1.

hCall:SET-PARAMETER(1, "SHORT", "INPUT-OUTPUT", mCnts).
hCall:INVOKE( ).