Hi All,
Has anyone done any CRC calculation with Progress? I need to send an image to a Zebra printer, and it insists on needing a crc-ccitt string is 4 digit hex.
I have a VB example that I am trying to convert to Progress, but it is going to involve a lot of fiddling with "fake" variables when dealing with "hi" and "lo" bits, and not-so-simple "xor":
I'm just wondering if anyone has any experience which can save me the best part of a day (or more!) trying to make this work!
Thanks in advance!
Has anyone done any CRC calculation with Progress? I need to send an image to a Zebra printer, and it insists on needing a crc-ccitt string is 4 digit hex.
I have a VB example that I am trying to convert to Progress, but it is going to involve a lot of fiddling with "fake" variables when dealing with "hi" and "lo" bits, and not-so-simple "xor":
Code:
Private Function CRC16(ByVal crc As Integer, d As Byte) As Integer
Dim carry As Integer, i As Byte
For i = 0 To 7
carry = (crc And 1) Xor IIf(d And (2 ^ i), 1, 0)
crc = (crc And &HFFFF&) \ 2
If carry <> 0 Then crc = crc Xor &H8408
Next i
CRC16 = crc
End Function
Public Function CalcCrc16(ByVal buf As String) As String
Dim crc As Integer, t As Integer
crc = &H8408
For t = 1 To Len(buf)
crc = CRC16(crc, Asc(Mid$(buf, t, 1)))
Next t
CalcCrc16 = Chr$(HiByte(crc)) & Chr$(LoByte(crc))
End Function
I'm just wondering if anyone has any experience which can save me the best part of a day (or more!) trying to make this work!
Thanks in advance!