>*============================================================================== >* Procedure: GUID >* Purpose: Generates a Universally Unique 16 Character Binary Id >* Author: F1 Technologies >* Parameters: >* Returns: lcGuid, the unique id >* Notes: If the results of this function are stored in a field the >* field should be a Character Binary field with a size of 16. >* Added: 11/10/99 >*============================================================================== >function GUID > >local lcGUID, lcString1, lcString2, lcString3, lcString4 > >lcGUID = UUID() >*--Convert the binaries to hex values >lcString1 = BINTOHEX(substr(m.lcGUID, 1, 4)) >lcString2 = BINTOHEX(substr(m.lcGUID, 5, 4)) >lcString3 = BINTOHEX(substr(m.lcGUID, 9, 4)) >lcString4 = BINTOHEX(substr(m.lcGUID, 13, 4)) > >lcGUID = m.lcString1 + m.lcString2 + m.lcString3 + m.lcString4 > >lcGUID = left(m.lcGUID, 8) + ; > substr(m.lcGUID, 10, 4) + substr(m.lcGUID, 15, 4) > >return m.lcGUID > >endfunc > >*=========================================================================== >* End: GUID >*=========================================================================== > >*============================================================================== >* Procedure: BINTOHEX >* Purpose: Converts a binary string to character string of hex. >* Author: F1 Technologies >* Parameters: lcBin >* Returns: The converted character string >*============================================================================== >procedure BINTOHEX > >lparameters lcBIN > >local lcChars, lnBin, lnDigit > >lcChars = "" > >for lnDigit = 1 to len(m.lcBIN) > lnBin = asc(substr(m.lcBIN, m.lnDigit, 1)) > lcChars = m.lcChars + ; > HEXTOCHAR(int(m.lnBin/16)) + ; > HEXTOCHAR(mod(m.lnBin,16)) >endfor > >return m.lcChars > >endproc >*=========================================================================== >* End: BINTOHEX >*=========================================================================== > >*============================================================================== >* Procedure: HEXTOCHAR >* Purpose: Converts a hex number to a character >* Author: F1 Technologies >* Parameters: lnHex, the hex number >* Returns: lnHex >*============================================================================== >procedure HEXTOCHAR >lparameters tnHex > >local lnAsc > >do case >case between(m.tnHex,0,9) && 0-9 maps to numbers where ASC48 = 'O' > lnAsc = 48 + m.tnHex > >case between(m.tnHex,10,15) && 10-15 maps tp letters where ASC65 = "A" > lnAsc = 65 + m.tnHex - 10 > >endcase > >return (chr(m.lnAsc)) > >endproc >*=========================================================================== >* End: HEXTOCHAR >*=========================================================================== >function UUID > >local lcUUID > >declare integer UuidCreate in rpcrt4.dll string @ UUID > >lcUUID = space(16) > >* Pass lcGUID to the UUIdCreate function >UuidCreate(@lcUUID) > >return m.lcUUID > >endfunc >*=========================================================================== >* End: UUID >Oh my! Good I asked to change your GUID generation.
* Try moving declaration into myGuid when you really have time to wait Declare Integer UuidCreate In 'RPCRT4.dll' String @pguid Declare Integer StringFromGUID2 In 'Ole32.dll' ; string rguid, String @lpsz, Integer cchMax start = SECONDS() FOR ix=1 TO 100000 x=myGUID() ENDFOR ? SECONDS()-m.start FUNCTION myGUID Local pGUID,rGUID pGUID=Replicate(Chr(0),16) rGUID=Replicate(Chr(0),80) UuidCreate(@pGUID) RETURN pGUID && 16 chars version - comment this and uncomment below for 38 version *StringFromGUID2(pGUID,@rGUID,40) *RETURN Strconv(Left(rGUID,76),6) && 38 chars versionCetin