Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Reverse a GUID? Fastest way?
Message
From
21/03/2008 21:52:04
 
 
To
21/03/2008 19:17:34
Mike Yearwood
Toronto, Ontario, Canada
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01304506
Message ID:
01304510
Views:
18
>Hey all
>
>It's easy enough to take a string and reverse it...
>
>
LPARAMETERS m.tcString
>LOCAL m.lnI, m.lcTemp
>m.lcTemp = ""
>FOR m.lnI = LEN(m.tcString) TO 1 STEP -1
>  m.lcTemp = m.lcTemp + SUBSTR(m.tcString,m.lnI,1)
>ENDFOR m.lnI
>RETURN m.lcTemp
>
>But I would like a faster way.
>
>Given a 128 Bit (16 Byte) GUID, how can it be reversed except for that?
>
>I played with CTOBIN(BINTOC()) but while I'm getting close, it's just not exact.
>
>Starting with this GUID, 009A946C98F7DC1181E3000D56EC5F75, I'd like to see it become 755FEC560D00E38111DCF7986C949A00
>
>Thanks

Lets see is this is faster, I broke it down for clarity:
Local ;
	m.lcGuidString As String, ;
	m.lcGuid As String, ;
	m.lcGuid1 As String, ;
	m.lcGuid2 As String


m.lcGuidString = "00112233445566778899AABBCCDDEEFF"

m.lcGuid = Strconv(m.lcGuidString, 16)

m.lcGuid1 = Left(m.lcGuid, 8)
m.lcGuid2 = Right(m.lcGuid, 8)

m.lcGuid1 = BinToC(CToBin(m.lcGuid1, "BRS"), "BRS")
m.lcGuid2 = BinToC(CToBin(m.lcGuid2, "BRS"), "BRS")

m.lcGuid = m.lcGuid2 + m.lcGuid1

?m.lcGuidString
?Strconv(m.lcGuid, 15)
Carlos
Previous
Reply
Map
View

Click here to load this message in the networking platform