Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
The Mother of Unique IDs
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00009899
Message ID:
00009921
Vues:
50
>I just made some tests and it seems to me that the random function RAND() is near 10000000 reliable than yours. But I'm not very sure that I correctly tested. It's too much...
>
>Anyway, what you need is something like that:
>This should replace your day(date()):
>
>Function Last2Digits
> Local CurrDate, AproxDayOfYear
> CurrDate=date()
> AproxDayOfYear=(month(CurrDate)*31+day(CurrDate)*100+;
> mod(year(CurrDate),100)
>Return chr(int(AproxDayOfYear/256))+chr(mod(AproxDayOfYear,256))

>
>Function UniqueKey
> Local RetValue, L2D
> RetValue=seconds()
> L2D=Last2Digits()
> do while RetValue = seconds() && Waits until seconds is changed
> enddo
>Return str(Retvalue*1000,8)+L2D
>
>This is a real unique value in a century!!!

Vlad

Let's face it. NO system is 100% foolproof. That's why I check for existing values & trap errors.

I have always loved putting sticks in Bee hives! (s)

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/
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform