Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Selecting a Winner
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00226460
Message ID:
00226926
Vues:
29
>>>=RAND(-1) && Initialize to system clock
>>>SELECT table
>>>COUNT TO nMaxValue FOR !DELETED()
>>>nWinnerRecord=INT(1+RAND()*nMaxValue)
>>>GO nWinnerRecord && This is the winning record
>>
>>:)) You forgot the deleted records just before your last line of code. :)
>
>I thought he just assumed SET DELE ON, the usual state, so COUNT will return only the non-deleted records. After all, if it's OFF, then the code can break anyway, since you may GO to a deleted record...so his code is either okay, or else the slight addition of !DELETED() will not help it...make sense?

Let me add that if there are deleted records, the code can still break...if there are deleted records, better to PACK or dump into a cursor before the code is applied...not as simple as everyone thought at first, I guess :)
The Anonymous Bureaucrat,
and frankly, quite content not to be
a member of either major US political party.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform