>>Does anyone know how I can create an index that would allow me to set a random order? Thanks,
>>John
>
>Do you want the
same apparently random order each time your application uses the random order, or do you require that the order change each time it is used?
>
>If the later, then you will need to bebuild the index each time it is used.
>
>Do you need this index to view a
set of records, for example in a BROWSE or GRID? Or, do you merely wish to process
individual records one at a time in a random order?
>
>If the later, then you could simply use:
GOTO (MAX( MIN( (RAND()*RECCOUNT()), RECCOUNT() ), 1 ))
Actually, it's the mention of the reccount() which will give you less than possibly uniform distribution if you use it in an index. I've indexed on just RAND() when I needed it, and it worked just fine. Used it when I wanted to have a random order in a .mp3 player I wrote, but that'd be a long story.
BTW, without an index, GoTo int(rand()*reccount()+1) - no mins, no maxes. I've used that too in the above player, but it gives you a better chance of repeating a record. The probability decreases with the number of records, but it's never zero (actually, I did hear some songs twice). Indexing on RAND() will give you a one-time random ordering, and then processing the records sequentially will make sure they don't repeat in the same cycle. Now adding records will only scatter them among the existing records - and the strategy for such a case would rather depend on the original intention.