CRC16校验法在powerbuilder10.5中的写法。
翻译C语言的数据类型
翻译成pb代码的CRC16算法
global type calccrc from function_object
end type
forward prototypes
global function unsignedinteger calccrc (byte crcbuf, unsignedinteger crc)
end prototypes
global function unsignedinteger calccrc (byte crcbuf, unsignedinteger crc); byte i;
crc = BitEx(crc , crcbuf);
for i = 0 to 7
byte chk;
chk = Bitand(crc, 1);
crc = RShift(crc ,1 ) ;
crc = Bitand(crc ,32767)// 0x7fff;
if (chk = 1) then
crc = BitEx(crc,40961) //0xa001;
end if
crc = Bitand(crc ,65535)// 0xffff;
next
return crc;
end function