Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Unique ID
Message
De
30/08/2004 12:43:24
 
 
À
30/08/2004 09:39:50
Steven Dyke
Safran Seats USA
Texas, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Divers
Thread ID:
00937563
Message ID:
00937686
Vues:
11
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"
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform