Random #'s

James Hurley jhurley at infostations.com
Thu Jan 27 09:46:27 EST 2005


>
>Message: 19
>Date: Thu, 27 Jan 2005 19:31:39 +1000
>From: "D.Rothe" <drothe at optusnet.com.au>
>Subject: Random #'s
>To: <use-revolution at lists.runrev.com>
>Message-ID: <000501c50453$01f97710$a6fe1dd3 at p4c2ghz>
>Content-Type: text/plain;	charset="iso-8859-1"
>
>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
>


Dwayne,

You might try something like:

on mouseUP
   put "" into tList
   repeat until the number of items in tList is 6
     put random(10) into tNum
     if tNum is not in tList then put tNum & ", " after tList
   end repeat
   delete last item of tList
   put tList into fld 1
end mouseUP

Jim




More information about the Use-livecode mailing list