Hi All,

I'm hoping someone can help me here. I have been at this no for sometime and am starting to get

the s**ts with it.

I created a DLL (C+) for CRC (16) checking. It seems to work fine when it is just a simple Visual C+ project, where a Main function calls the routine, and displays the CRC. However when I compile it into a DLL and call from Progress it gives me the wrong CRC numbers. I think it is the way a return the CRC value. In the C++ project I wasn't physically returning the value as I only send the memory pointer and therefore can refernce it without having to specifically RETURN the value. With the progress call that doesn't seem to be possible, I have to physically pass back the value. Please find below the code for the DLL and the Progress Call:

C++ code:

/********************************************************************

* Filename: CRC16

* Version: 1.0

*

* Date of Creation: 24/11/2000

* Author: Wayne Singh

* Description: Calculates CRC-16 for Character

*

* Input: - Current CRC value (unsigned short)

* - Next character in string (char)

*

* Output: - New CRC value (unsigned short)

*

********************************************************************/

#include <windows.h>

extern "C" unsigned short _declspec(dllexport) WINAPI CheckCRC(unsigned short *CRCWord, char character)

{

unsigned int vCtr;

unsigned int carry;

char x16;

unsigned int value;

value = int (character);

for (vCtr = 0; vCtr < 8; vCtr++) {

x16 = (value & 1) ^ (*CRCWord & 1);

value = value >> 1;

if (x16 == 1) {

*CRCWord = *CRCWord ^ 0x4002;

carry = 1;

}

else if (x16 != 1) {

carry = 0;

}

*CRCWord = *CRCWord >> 1;

if (carry == 1) *CRCWord = *CRCWord | 0x8000;

else if (carry == 0) *CRCWord = *CRCWord & 0x7fff;

}

return(*CRCWord);

}

Progress Code:

/*

I am using this file simply to test my CRC16 dll functionality

*/

def var vString as char no-undo format "X(20)".

def var vChar as char no-undo.

def var vCRC as int no-undo.

def var vLength as int no-undo.

def var vCount as int no-undo.

update vString.

vLength = length(vString).

vCRC = 0.

do vCount = 1 to vLength:

vChar = substring(vString,vCount,1).

run CheckCRC (input vCRC,

input vChar ,

output vCRC).

end.

message "CRC returned was " + string(vCRC) view-as alert-box.

procedure CheckCRC external "CRC16.dll":

def input param ipCRC as short no-undo.

def input param vChar as char no-undo.

def return param opCRC as short no-undo.

end procedure. /* CheckCRC */

I am testing with this string #POL0040101, which should return a value of 49116 or BF DC (Hex).

Please if anyone can help it would be really appreciated. I have been told there is a way to specify memory pointers in progress and was wondering if maybe if I sent in the memory pointer than I may not have to physically RETURN the value.

Thank you very much in advance.

Wayne Singh