deepzero Posted February 27, 2010 Share Posted February 27, 2010 Hi, i need to understand this line of foxpro 9.0 code: serial = VAL(SYS(2007, ALLT(STR(THISFORM.TEXT1.VALUE)))) * 2 1) it takes the string from text1 :STR(THISFORM.TEXT1.VALUE) 2) it removes all spaces using ALLT 3) it generates the crc of the string withput spaces 4) and multiplys it by 2 msdn about the sys(2007, xxx) function: http://msdn.microsoft.com/en-us/library/csfkkhcy%28VS.80%29.aspx and the val() function: http://msdn.microsoft.com/en-us/library/csfkkhcy%28VS.80%29.aspx an example: text1.value = "1 234" -> remove spaces: "1234" -> calc crc32b (??) 596A3B55 -> take first numbers: 596 -> mul by two: 1192 But what crc is used? And what if the crc starts with a char, e.g. deepzero - F94E6C43 Is all this actually correct? :help Link to comment
GaBoR Posted February 27, 2010 Share Posted February 27, 2010 (edited) CRC32B is used:/>http://tuts4you.com/download.php?view.550/>http://www.woodmann.com/forum/archive/index.php/t-7460.htmlAnd yes, all of that is correct. Edited February 27, 2010 by GaBoR Link to comment
till Posted February 27, 2010 Share Posted February 27, 2010 HelloI might be wrong as I have no knowledge at all of Fox Pro.But where does it state that that SYS(2007) function returns the checksum in hex?It would make more sense that the sys function returns a base 10 string, and thus you wouldn't have the problem with the serial being 0 in almost 50% of the cases of the text1 value.So convert your base16 number to a base10 one and then multiply it by two.Cheers,t. Link to comment
deepzero Posted February 28, 2010 Author Share Posted February 28, 2010 (edited) hi, till, you`re right, it retrunsa decimal b10 value! It`s using crc16 though. thanks you two! dp0 Edited February 28, 2010 by deepzero Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now