Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need sys(2007) in c#
Message
From
17/07/2014 14:41:58
 
 
To
17/07/2014 12:27:11
John Baird
Coatesville, Pennsylvania, United States
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
C# 4.0
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01603909
Message ID:
01603945
Views:
33
i found this vfp code that gives the same results as sys(2007)
http://fox.wikis.com/wc.dll?Wiki~CRC16

and this
lnCRC16 = SYS(2007,"String to be CheckSummed")
is the same result as this
lnCRC16 = STR(bobcrc(-1,"String to be CheckSummed","16"))

now I just have to figure out how to translate the below VFP code to c#

PARAMETERS lnStartVal, lcBlockTxt, lcBitLen
DO CASE
CASE PCOUNT() < 2
WAIT WINDOW "Not enough paramters passed to ";
+"CRC(lnStartVal, lcBlockTxt, lcBitLen) function."
RET4URN
CASE PCOUNT() < 3
lcBitLen = "16"
ENDCASE
DIMENSION laPower[8] && For the 8 laPowers of 2
PRIVATE lnCRC, lnPower, TestBit
lnBitLen = IIF(lcBitLen="32",32773,4129) && 1021 hex (16bit), 8005 hex (32bit)

* Precalculated values will improve performance in FOR J Code
FOR lnPower = 1 TO 8
laPower[lnPower] = 2^(lnPower-1)
NEXT lnPower

lnCRC = lnStartVal && Reset for Each Text Block
FOR OutLoop = 1 TO LEN(lcBlockTxt) && Calculate for Length of Block
ByteVal = ASC(SUBSTR(lcBlockTxt, OutLoop, 1))
FOR InLoop = 8 TO 1 STEP -1
TestBit = ((BITAND(lnCRC,32768) = 32768) AND NOT (BITAND(ByteVal, laPower(InLoop)) ;
= laPower(InLoop))) OR;
(!(BITAND(lnCRC,32768) = 32768) AND (BITAND(ByteVal, laPower(InLoop)) ;
= laPower(InLoop)))
lnCRC = BITAND(lnCRC,32767)*2
IF TestBit
lnCRC = BITXOR(lnCRC,lnBitLen)
ENDIF
NEXT InLoop
NEXT OutLoop
RETURN lnCRC && Return the Word Value
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform