Random #'s
Éric Chatonet
eric.chatonet at wanadoo.fr
Thu Jan 27 10:20:01 EST 2005
Hi Dwayne,
put GenerateRandom(6,10) -- the right parameters in your case
function GenerateRandom pHowMuchNumbers,pRange
local tRangeList
-----
repeat until the number of lines of tRangeList = pHowMuchNumbers
set the randomSeed to random(100000)
put random(pRange) into pNum
if pNum is not among the lines of tRangeList then put pNum & cr
after tRangeList
end repeat
delete char -1 of tRangeList
return tRangeList
end GenerateRandom
Hope this helps.
Le 27 janv. 05, à 11:34, "D.Rothe" <drothe at optusnet.com.au> a écrit :
> 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
Amicalement,
Éric Chatonet
24, Boulevard de Port-Royal
75005 Paris
Fixe : 33 1 43 31 77 62
Mobile : 33 6 20 74 50 89
More information about the use-livecode
mailing list