How to initiate a HANDLE TO LONG INPUT-OUTPUT PARAMETER for API call

okion

New Member
Hello,

I use a external dll:
PROCEDURE GetObject EXTERNAL "{&DLLNAME}" ORDINAL 209 {&PERSISTENT}:
DEFINE RETURN PARAMETER rc AS LONG.
DEFINE INPUT PARAMETER hDOMObj AS LONG.
DEFINE INPUT PARAMETER pszName AS CHARACTER.
DEFINE INPUT-OUTPUT PARAMETER phDOMSubObj AS HANDLE TO LONG.
END.

When i call the procdure i via

DEFINE VARIABLE h_ObjList AS HANDLE.
RUN GetObject(OUTPUT i_ObjListRet, i_ProjID, "Objects", INPUT-OUTPUT h_ObjList).
I got the message:
A variable or array element passed as an INPUT or INPUT-OUTPUT parameter to a DLL cannot contain the Unknown value.
The h_ObjList is the problem. Does anyone know how to initiate "HANDLE TO LONG" input-output parameter?
 

Marian EDU

Member
are you sure about that input-output parameter? if it's a handle it really doesn't have to be input-output, the memory pointer will be passed along. to gave a valid memory pointer you need to use a memptr which if it need to be initialized you have to call set-size() and optionally put something in it, then use get-pointer-value (i think) to get the handle (pointer).

if it's a handle to long i think you can simply pass it as long and progress will take care of it, same as for *char where you can safely pass a character for input parameters.
 

okion

New Member
It is a list & Label dll from combit and there progress help files gives the definition:
PROCEDURE LlDomGetObject EXTERNAL "{&CMLL15_DLLNAME}" ORDINAL 209 {&CMLL15_PERSISTENT}:
DEFINE RETURN PARAMETER rc AS LONG.
DEFINE INPUT PARAMETER hDOMObj AS LONG.
DEFINE INPUT PARAMETER pszName AS CHARACTER.
DEFINE INPUT-OUTPUT PARAMETER phDOMSubObj AS HANDLE TO LONG.
END.
But they did not provide an example how to call this procedure
 

Marian EDU

Member
i guess you can try to remove the 'handle to' option from the last parameter and pass an integer variable when calling the method...

Code:
PROCEDURE LlDomGetObject EXTERNAL "{&CMLL15_DLLNAME}" ORDINAL 209 {&CMLL15_PERSISTENT}:
DEFINE RETURN PARAMETER rc AS LONG.
DEFINE INPUT PARAMETER hDOMObj AS LONG.
DEFINE INPUT PARAMETER pszName AS CHARACTER.
DEFINE INPUT-OUTPUT PARAMETER phDOMSubObj AS LONG.
END.

def var ret      as integer.
def var obj      as integer.
def var subObj as integer.

run LlDomGetObject (ret, obj, "name", input-output subObj).

see if it works like that... if not, you can define a memptr variable, set the size to 8 and see if you get anything back in it... especially a long, try get-long(mp, 1)

Code:
def var ret      as integer.
def var obj      as integer.
def var subObj as memptr.

set-size(subObj) = 8.

run LlDomGetObject (ret, obj, "name", get-pointer-value(subObj)).

message get-size(subObj) skip get-long(subObj, 1).

but if you pass a handle I don't see why it has to be input-output.
 

okion

New Member
The solution was very simple. I used a variable from the integer type and it worked.
def var ret as integer.
def var obj as integer.
def var subObj as integer.
run LlDomGetObject (ret, obj, "name", INPUT-OUTPUT subObj).
 
Top