Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Unique ID
Message
From
30/08/2004 12:43:24
 
 
To
30/08/2004 09:39:50
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00937563
Message ID:
00937686
Views:
13
We get a guid:
*--GETGUID.PRG
*
*------------------------------------------------------------------------------------------------
*Example
*lnguid=getguid()
*?lnguid

DECLARE INTEGER CoCreateGuid ;
  IN Ole32.dll ;
  STRING @lcGUIDStruc
DECLARE INTEGER StringFromGUID2 ;
  IN Ole32.dll ;
  STRING cGUIDStruc, ;
  STRING @cGUID, ;
  LONG nSize

cStrucGUID=SPACE(16)
cGUID=SPACE(80)
nSize=40
IF CoCreateGuid(@cStrucGUID) # 0
   RETURN ""
ENDIF
IF StringFromGUID2(cStrucGUID,@cGuid,nSize) = 0
  RETURN ""
ENDIF
RETURN STRCONV(LEFT(cGUID,76),6)
You can strip out the { and - :
LPARAMETERS lresult
IF TYPE('lresult')="L"
	lresult = ''
ENDIF
lresult=getguid()
? lresult
RETURN

Function GetGuid()

	declare integer CoCreateGuid in ole32 string @	
	declare integer StringFromGUID2 in ole32 string,string @,integer 

	local guid, guidString, n, s
	guid = space(16)
	do case
	case empty(CoCreateGuid(@guid))
		guidString = space(78)
		n = StringFromGUID2(guid, @guidString,len(guidString))
		do case
		case n = len(guidString)/2
			s = chrtran(guidString, chr(0) + '-{}', '')
			return s
		otherwise
			assert FALSE
			return Null
		endcase

	otherwise
		assert FALSE
		return Null
	ENDCASE
	return guid

endfunc
Think I got the 2nd example originally from Sergey...

>What is the best method for creating a unique id for a record when multiole users are creating records at the same time?
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform