Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. sponsors. rss.
 From: Borislav Borissov
  Where is Borislav Borissov?
 Sofia
 Bulgaria
 Borislav Borissov
 To: Richard Clarke
  Where is Richard Clarke?
 Crowcombe
 United Kingdom
 Richard Clarke
 Tags
Subject: RE: Convert from C to VFP
Thread ID: 188183 Message ID: 188255 # Views: 54 # Ratings: 1
Version: Visual FoxPro 9 SP2 Category: Other
Date: Friday, August 08, 2008 11:04:23 AM         
   


> >
> >
> > FUNCTION CRC16(lnVal)
> >     LOCAL lnCRC, rip, lnFor
> >     lnCRC = 0
> >     FOR lnFor = 16 TO 0 STEP -1
> >         rip   = lnVal ^ lnCRC
> >         lnCRC = BITRSHIFT(lnCRC,1)
> >         lnVal = BITRSHIFT(lnVal,1)
> >         IF BITAND(rip, 1) # 0
> >            lnCRC = lnCRC ^ 0x11021
> >         ENDIF
> >     NEXT
> > RETURN lnCRC
> > 

> >
> > -----------------
> > Borislav Borissov
> >
> > Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
> > The only thing normal about database guys is their tables.
>
> Hello Borislav,
>
> It always returns zero?
>
>
> Richard

O GOD!!!
I always forgot that [^] is not POWER operator but XOR(), Sorry:
 FUNCTION CRC16(lnVal)
     LOCAL lnCRC, rip, lnFor
     lnCRC = 0
     FOR lnFor = 16 TO 0 STEP -1
         rip   = BITXOR(lnVal, lnCRC)
         lnCRC = BITRSHIFT(lnCRC,1)
         lnVal = BITRSHIFT(lnVal,1)
         IF BITAND(rip, 1) # 0
            lnCRC = BITXOR(lnCRC, 0x11021)
         ENDIF
     NEXT
 RETURN lnCRC





-----------------
Borislav Borissov

Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.



COMPLETE THREAD
Convert from C to VFP Posted by Richard Clarke @ 8/7/2008 10:57:34 PM
RE: Convert from C to VFP Posted by Borislav Borissov @ 8/8/2008 8:34:00 AM
RE: Convert from C to VFP Posted by Richard Clarke @ 8/8/2008 9:49:20 AM
RE: Convert from C to VFP Posted by Borislav Borissov @ 8/8/2008 9:53:57 AM
RE: Convert from C to VFP Posted by Richard Clarke @ 8/8/2008 10:11:38 AM
RE: Convert from C to VFP Posted by Borislav Borissov @ 8/8/2008 11:04:23 AM
RE: Convert from C to VFP Posted by Richard Clarke @ 8/8/2008 4:13:19 PM
RE: Convert from C to VFP Posted by Anders Altberg @ 8/8/2008 6:44:37 PM