OCX Problem

OCX Problem - Passing Com-handle as parameter

Hi all,

On the verge of tairing my hair out here.

Have an third-party OCX for retrieving a weight from a scales.

Basically, I am having a problem with one method. When I view the method using the Progress COM object viewer, I get the following.....

[ Logical-Var = ] <com-handle>: GetWeight (
INPUT-OUTPUT Com-Handle-alibiWeighing BY-POINTER,
INPUT-OUTPUT Integer-errNumber BY-POINTER,
INPUT-OUTPUT Character-errString BY-POINTER ).

My Progress code is as follows:

ON CHOOSE OF btnWeight
DO:
DEFINE VARIABLE chWeighing AS COM-HANDLE.
DEFINE VARIABLE iErrNo AS INTEGER.
DEFINE VARIABLE cErrString AS CHARACTER.
DEFINE VARIABLE lLog AS LOGICAL.

lReturn = chScales:GetAlibiWeight(INPUT-OUTPUT chWeighing,
INPUT-OUTPUT iErrNo,
INPUT-OUTPUT cErrString)
END.

All seems fine but when I run the code, I get the following error message:

Error occurred while accessing component property/method GetAlibiWeight
Type Mismatch.
Error Code: 0x80020005 USER-INTERFACE-TRIGGER c:\test\testcomm.r

I have referenced other methods of this OCX without any problem. This method is different in that it has a com-handle as an input-output parameter.

Anyone have any ideas why I'm getting this error. Any help would be greatly appreciated as I'm running way behind my deadline with this...

Oh yeah,
Progress V9.1C
Windows NT.

Regards,
paul.
 

BelaB

New Member
Perhaps you have to define memory pointers (memptr) instead of characters, integers oder logicals.
Only an idea ;)
 

BONO

Member
Hello,
The method u've wrote about progress pro tools is GetWeight and not GetAlibiWeight, is it a mistake?
 

bendaluz2

Member
Think BellaB has hit the nail on the head here, you need to do something like this:

Code:
ON CHOOSE OF btnWeight
DO: 
    DEFINE VARIABLE chWeighing AS COM-HANDLE.
    DEFINE VARIABLE iErrNo AS INTEGER.
    DEFINE VARIABLE cErrString AS CHARACTER.
    DEFINE VARIABLE lLog AS LOGICAL.
    DEFINE VARIABLE mWeighing AS MEMPTR.
    DEFINE VARIABLE mErrNo AS MEMPTR.
    DEFINE VARIABLE mErrString AS MEMPTR.

    SET-SIZE(mWeighing) = 4.
    SET-SIZE(mErrNo) = 4.

    PUT-LONG(mWeighing,1) = INTEGER(chWeighing).
    
    lReturn = chScales:GetAlibiWeight
        (INPUT-OUTPUT mWeighing, 
         INPUT-OUTPUT mErrNo,
         INPUT-OUTPUT mErrString)
    
    iErrNo = GET-LONG(mErrNo,1).
    cErrString = GET-STRING(mErrString,1).

    SET-SIZE(mWeighing) = 0.
    SET-SIZE(mErrNo) = 0.
    SET-SIZE(mErrString) = 0.
END.

Not sure what you would initialize the size of mErrString to, so i've left it out, though you may have to address this issue. Good luck!
 
Top