Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Unique key
Message
From
30/10/2010 16:24:38
 
 
To
30/10/2010 16:14:45
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP1
Miscellaneous
Thread ID:
01487630
Message ID:
01487650
Views:
90
This message has been marked as a message which has helped to the initial question of the thread.
Well, GUIDs are long because they're aimed at being globally unique - or to be more exact, to make the chances of a collision vanishingly small.

If you're just concerned with getting unique strings on different machines on the same LAN, you could prepend or append the computer's NetBIOS name (the first part of SYS( 0 )) to any other string you generate. That name must be unique for all computers on a LAN.

However, if you run more than one instance of your program on a single computer, those instances will share the same NetBIOS name (although, as pointed out elsewhere their ProcessID values will be different).

>Al, thank you!
>
>I had looked at
>
>oGUID = CreateObject("scriptlet.typelib")
>cGUID = substr( oGUID.GUID, 2, 36 )
>? cGUID
>
>
>but wanted a shorter key that I could also use as a filename.
>
>dg
>
>>You may want to look at GUIDs for this sort of thing: http://fox.wikis.com/wc.dll?Wiki~GUIDGenerationCode~VFP
>>
>>>Thank you. I want to be able to order this key by chronology, so do I understand that
>>>
SUBSTR(SYS(2015),2, 9)+TRANSFORM(_vfp.ProcessId)
>>>would yield unique id's created on different machines at the precise same moment?
>>>
>>>dg
>>>
>>>
>>>
>>>>Adding ProcessId to should make the key unique
>>>>
>>>>transform(_vfp.ProcessId)+SYS(2015) 
>>>>
>>>>>I am creating a unique key with substr(SYS(2015),2, 9) as the value. Would it require that 2 users on 2 machines create the key at the same millisecond to get a duplicate, or even at the precise same moment would different machines render different values?
>>>>>
>>>>>Thanks.
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform