>i'm doing some work in C# and need to have a working version of a method that correctly translates the sys(2007,"foo") to the same value in c# that it calculates using the built-in vfp method. does anyone have any ideas or code for sys(2007) in c#.
>
>here's the docs for the sys(2007) method in vfp
>
>
http://msdn.microsoft.com/en-us/library/csfkkhcy(v=vs.80).aspxalso found this:
The algorithm used by Sys(2007) is as follows:
*********************************
static unsigned char ObjectCheckSum = 0;
//+----------------------------------------------------------------------
---- // // Function: CalcCkSum, private // // Synopsis: Calculates the
checksum for a general field. // // Arguments: [ptr] -- pointer to data
to calculate checksum on. // [cb] -- number of bytes in the buffer. //
// Modifies: ObjectCheckSum //
//-----------------------------------------------------------------------
----
LOCAL void CalcCkSum(void *ptr, long cb)
{
long cktemp = 0;
long cl = cb >> 2;
long *lp = (long *) ptr;
TEXT *cp;
while(cl--)
cktemp ^= *lp++;
cl = cb & 3; // Any remainder?
cp = (TEXT *)lp;
while(cl--)
cktemp ^= *cp++;
ObjectCheckSum ^= cktemp;
ObjectCheckSum ^= cktemp >> 8;
ObjectCheckSum ^= cktemp >> 16;
ObjectCheckSum ^= cktemp >> 24;
}
http://computer-programming-forum.com/2-vfp/ac93d844790b80c7.htm