Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Reverse a GUID? Fastest way?
Message
De
22/03/2008 10:58:11
Mike Yearwood
Toronto, Ontario, Canada
 
 
À
22/03/2008 07:06:25
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Divers
Thread ID:
01304506
Message ID:
01304560
Vues:
19
Gregory

>The fastest I have found (for null terminated strings)
>// http://msdn2.microsoft.com/en-us/library/9hby7w40(VS.71).aspx
>
>The execution time on my computer (vfp9sp2) in a loop (i = 1 to 1000000) is 14 sec for your function compared to 1.8 for StringReverse()
>
>
>function StringReverse(s)
>
>	declare string  _strrev in msvcrt.dll as StringReverse string
>	
>	return StringReverse(m.s)
>endfunc
>
That sounds good! If I have 16 bytes where one of the bytes is 00, it seems to stop at that byte. I need it to go for the length of the provided string.

Here's what I've run. If I'm missing something, please let me know.

Thanks!
DECLARE INTEGER UuidCreateSequential ;
	IN Rpcrt4.Dll ;
	STRING @ lcGUID

declare string  _strrev in msvcrt.dll as StringReverse string

DECLARE INTEGER StringFromGUID2 ;
	IN Ole32.DLL ;
	STRING rguid, STRING @lpsz, INTEGER cchMax

LOCAL m.lcGUID
m.lcGUID = REPLICATE(CHR(0),16)
UuidCreateSequential(@m.lcGUID)
?GuidFormat3(m.lcGuid)

m.lcGuidRev = StringReverse(m.lcGUID)

?GuidFormat3(m.lcGuidRev)
RETURN

PROCEDURE GuidFormat3
LPARAMETERS m.lcBuffer
LOCAL m.lcPK,m.i,m.lnHex,m.lnUpper,m.lnLower
m.lcPK=SPACE(0)
FOR m.i=1 TO 16
	m.lnHex = ASC(SUBSTR(m.lcBuffer,m.i,1))
	m.lnUpper = INT(m.lnHex/16)
	m.lnLower = m.lnHex - (m.lnUpper*16)
	m.lcPK = m.lcPK + SUBSTR('0123456789ABCDEF',m.lnUpper + 1,1) + ;
		SUBSTR('0123456789ABCDEF',m.lnLower + 1,1)
ENDFOR
RETURN m.lcPK
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform