Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Random records from many area
Message
From
05/09/2006 06:02:15
 
 
To
04/09/2006 08:08:49
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP
Miscellaneous
Thread ID:
01150681
Message ID:
01150856
Views:
22
>hi all,
>i need help to mdify at this code under ,
>
>my filed name is(code) have numbers form 1 to 14
>
>for i= 1 to 3
>1.i need to get 900 records randomly for every code
>
>2.for i=4, i need 750 records randomly
>
>3.for i=5 to 14, i need 450 records randomly for every code
>
>
>
>
>
>CLOSE all
>USE RIS_SEG_2
>
>total = "450"
>*total = (THISFORM.TEXT1.VALUE)
>RAND(-1)
>INDEX ON RAND() TO SYS(2023)+'\RANDOM'
>*COPY TO \SELECTION NEXT &total
>COPY TO rf2 NEXT &total
>brow
>SET INDEX TO
>ERASE SYS(2023)+'\RANDOM'
>      CLEAR EVENTS
>
> thanks

try
CLOSE all

USE RIS_SEG_2
COPY TO \SELECTION NEXT 0

RAND(-1)
INDEX ON Code+RAND() TO SYS(2023)+'\RANDOM'

FOR _code=1 to 14
 endCount=RECCOUNT('SELECTION')+ICASE(m._code<4,900,m._code=4,450,750)
 SCAN REST WHILE RECCOUNT('SELECTION') < m.endCount FOR Code=m._code && this can to be optimized
   SCATTER MEMO NAME recBuffer
   INSERT INTO SELECTION FROM NAME recBuffer
 ENDSCAN 
NEXT
release recBuffer
SET INDEX TO
ERASE SYS(2023)+'\RANDOM'

SELECT SELECTION
brow
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform