Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Hash() Function in VFP
Message
From
24/10/2002 01:03:39
 
 
To
21/10/2002 09:44:57
Lakhani Anil
Lakhani Software Solutions
Mumbai, India
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Miscellaneous
Thread ID:
00713481
Message ID:
00714672
Views:
63
>Hi All,
>
>How can we use Hash() Function in VFP, as we are using it in VB & Java to generate unique key from a name string?
>
>Anil Lakhani
* here is a 31 bit hash function, remember that hashes are not quaranteed to be
* unique

FUNCTION hash (tcString)
LOCAL i, lnHash, lcString

lnHash = 0

lcString = tcString + REPLICATE(CHR(0), 4)

FOR i = 1 TO LEN(tcString) STEP 4
	lnHash = BITCLEAR(BITXOR(lnHash, CTOBIN(SUBSTR(lcString, i, 4))), 31)
ENDFOR

RETURN lnHash
Previous
Reply
Map
View

Click here to load this message in the networking platform