Random #'s
Raymond E. Griffith
rgriffit at ctc.net
Thu Jan 27 08:20:17 EST 2005
> Hi All,
> I am using the following code to generate a field of 6 random numbers.
>
> repeat 5 times --generate list of 5 random numbers between 1-10
> put random(10) & "," after tRnum
> end repeat
> delete last char of tRnum --delete last comma
> put tRnum into fld "numbers"
>
> this works fine but some numbers are repeated in the field, e.g (1,2,3,1,5)
> How can I include only unique numbers?
>
> Cheers......Dwayne
Hmmm.
put "1,2,3,4,5,6,7,8,9,10" into tlist
repeat with i = 10 down to 6
put random(i) into x
put item x of tlist into item(i - 9) of tRnum
delete item x of tlist
end repeat
put tRnum into fld "numbers"
OR
put "1,2,3,4,5,6,7,8,9,10" into tlist
sort items of tlist by random(100)
put item 1 to 6 of tlist into fld "numbers"
Regards,
Raymond
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
More information about the use-livecode
mailing list