Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Random Record Selection Problems.
Message
 
 
À
15/12/2003 15:22:26
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00859259
Message ID:
00859323
Vues:
19
Hi Quinn,

Several years ago I worked on a random generator for Boise Cascade out here in Idaho. For the forest service we needed a true random selector for scale loads coming into the mills.

What you are doing is on the right track. Here's a portion of our code:


select file
replace all fedit with 0
=rand(-1) && To achieve the most random sequence of numbers, issue
&& RAND( ) initially with a negative argument and then
&& issue RAND( ) without an argument.
tcnt = 0
do while .t.
mchoose = int(reccount() * rand())
if between(mchoose,0,reccount()-1)
go top
skip mchoose
replace fedit with 1
tcnt = tcnt + 1
endif
if tcnt > reccount() * .2
exit
endif
enddo

You now have 20% of your records ramdomly selected.

Hope this helps

Bruce

-------------------------------------------------
There is no nobility in being superior to
anyone else; nobility is derived from being
superior to that which you were yesterday
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform