rcozens at pon.net
Fri Jan 28 12:48:36 EST 2005
> > 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?
function uniqueRandomNumberList listEntryCount, maxListNumber -- You would
if listEntryCount < 1 then return empty
put empty into numberList
put empty into returnValue
repeat with x = 1 to maxListNumber
put x&return after numberList
get the random of maxListNumber
put line it of numberList after returnValue
delete line it of numberList
subtract 1 from listEntryCount
if listEntryCount < 1 then return returnValue
put comma after returnValue
subtract 1 from maxListNumber
More information about the Use-livecode