How do I pick randomly five lines out of vChooseFrom, putting them into
vSelected:
function randomList vNumToChoose,@vChooseFrom
put return into vSelected
add 1 to vNumToChoose
repeat while the number of lines of vSelected < vNumToChoose
get (any line of VChooseFrom)&return
if offset(return&it,vSelected) = 0 then put it after vSelected
end repeat
return char 2 to -1 of vSelected
end randomList

If vNumToChoose is relatively small compared to the number of lines of vChooseFrom, this should be reasonably efficient. If vNumToChoose is relatively close to the number of lines of vChooseFrom, it will require significantly more repeats to do the job; thus Dar's "delete from list approach" may provide better performance.
--

Rob Cozens
CCW, Serendipity Software Company
http://www.oenolog.com/who.htm

"And I, which was two fooles, do so grow three;
Who are a little wise, the best fooles bee."

from "The Triple Foole" by John Donne (1572-1631)
_______________________________________________
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution


Reply via email to