Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Random Record Selection Problems.
Message
From
15/12/2003 16:55:57
 
 
To
15/12/2003 15:22:26
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00859259
Message ID:
00859323
Views:
18
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
Previous
Reply
Map
View

Click here to load this message in the networking platform