[REBOL] RANDOM's & PICK's args
From: ddalley::idirect::com at: 19-Jan-2002 19:03
I am trying to PICK a set (say 3-9) of random, non-duplicated strings out
of a block of 50. The strings are to be presented as a row of BUTTONs.
BUTTON needs a string...
How do we use >both< a RANDOM range and a seed, at the same time?
The docs don't show how and all efforts, so far, have failed.
Also, PICK always complains that the index arg is of the wrong type, when I
try to combine the two procedures. I used a word & a number, but it didn't
work with either.
The following are some ideas I used, but getting a random string has never
worked, so it has become messy:
balls: [ "String 1" "String 2" "String 3 " ... "String 50" ]
b-seed: RANDOM 50
pick-string FUNC [ "Picks a random string from balls." balls b-seed][
PICK balls (PROBE b-seed)
; yes, more work is needed here
Tried to display each string with something like
BUTTON pick-string MAROON 50x50 FONT-SIZE 32
but now the string does not display in the button.
I was thinking that removing each string from balls, when picked, would
ensure that there were no duplicates, but I haven't tried yet. CLEAR, CHANGE
& REMOVE are like using a chainsaw, therefore I presume REPLACE is needed to
delete just one element from a series/block. How can REPLACE be used to not
leave a blank string in the block, so that it can't be picked? This would
also affect RANDOM's range the way I am using it.
Any help/ideas will be appreciated.