random
Sarah Reichelt
sarah.reichelt at gmail.com
Sun Mar 12 20:09:23 EST 2006
On 3/13/06, liamlambert <liamlambert at mac.com> wrote:
> I have this code for a random number in 6
> fld's how do I stop the same number form appearing
> in more then one fld
>
> put "1a,2a,3a,4a,5a,6a" into tFieldNames
> repeat for each item tfield in tFieldNames
> put the random of 45 into trandom
> put trandom into fld tfield
> end repeat
>
This is the sort of question that always produces lots of methods, but
here's one possibility:
-- build a list of the numbers from 1 to 45
put empty into tNumberList
repeat with x = 1 to 45
put x & cr after tNumberList
end repeat
-- sort this list randomly
sort lines of tNumberList by random(10000)
-- use the first 6 numbers to fill your fields
put "1a,2a,3a,4a,5a,6a" into tFieldNames
repeat for each item tfield in tFieldNames
put line 1 of tNumberList into fld tfield
delete line 1 of tNumberList
end repeat
Cheers,
Sarah
More information about the use-livecode
mailing list