Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
The Mother of Unique IDs
Message
 
To
19/10/1996 04:25:44
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00009899
Message ID:
00010540
Views:
46
>>OK, have my Kevlar on. I decided to create a solid unique ID number generator. The only restriction I used was to stay within the 10 character default field length. The value I came up with, I figure, has an odds of 1 in 2.59 billion chance of being reproduced (duplicated) in Windows & 1 in 259 million chance in NT.
>>
>>Check it out:
>>
>>int(seconds() *100000 + day(date()))
>>
>>The resolution of seconds on an NT machine is 10 thousandths. In 95 an older, 1 thousandths. On a 133 Pentium I held down the CTRL+Y key and added records. Even in the NT setup no 2 records were ever near identical. It ain't perfect but it is getting close.
>>
>>Tom
>
>
>Hi Tom,
>
>Sorry I thnik I pressed 'default' on the last message. Here it is again just in case.
>
>You can generate unique ID's using a built in function of VFP. It is meant to generate unique procedure names but I use it for unique ID's. It works on the same principle as your code but will be faster. Here is the wording from the VFP help file :
>
>The name that SYS(2015) returns is created from the system date and system time. Calling SYS(2015) more than once during the same millisecond interval will return a unique character string.

Jos

Yeah, we had a discussion on this. It all began when someone was generating IDs & getting Unique Index errors. I was trying to come up with a method that is more unique then sys(2015). I guess the bottom line that I forgot to mention is I SEEK() the table to look for a duplicate ID. If found I loop & retieve another ID & do it again.

Thanks
Tom
Tom
--------------------------------
Tom O'Hare
407-299-4268 -- tom@redtile.com -- http://www.redtile.com/
Independent Programmer Using Visual FoxPro, Visual Basic & more...
Operations Manager -- Virtual FoxPro User Group (VFUG)
http://www.vfug.org/ -- tom@vfug.org
President -- Central Florida FoxPro User Group (CFFUG)
http://www.redtile.com/foxpro/
Universal Thread Most Valued Professional (MVP)
http://www.transformation.com/foxpro/
Previous
Reply
Map
View

Click here to load this message in the networking platform