item random() (was Random(3) often returns 1)
Mark Schonewille
m.schonewille at economy-x-talk.com
Thu Jun 8 19:59:49 EDT 2006
Hi Geoff,
Funny, that's exactly what I demonstrated in a previous e-mail,
earlier to/yesterday. Apparently, there is more than one workaround.
Maybe a slight pause is all it takes.
Best,
Mark
--
Economy-x-Talk
Consultancy and Software Engineering
http://economy-x-talk.com
http://www.salery.biz
Download ErrorLib at http://economy-x-talk.com/developers.html and
get full control of error handling in Revolution.
Op 9-jun-2006, om 1:35 heeft Geoff Canyon het volgende geschreven:
> I just ran this code
>
> on mouseUp
> repeat 1000
> add 1 to x[random(3)]
> end repeat
> put sum(x) into y
> combine x using cr and tab
> put x & cr & cr & y
> end mouseUp
>
> and got this:
>
> 1 329
> 2 328
> 3 328
>
> 985
>
>
> Note that the three numbers don't add up to 1000, but there are no
> other numbers. ???
>
> Running it again I get:
>
> 1 339
> 2 335
> 3 338
>
> 1012
>
>
> _More_ than 1000? What the???
>
> Even stranger, making this slight adjustment fixes it:
>
> on mouseUp
> repeat 1000
> put random(3) into z
> add 1 to x[z]
> end repeat
> put sum(x) into y
> combine x using cr and tab
> put x & cr & cr & y
> end mouseUp
>
> Anyone know what I'm not seeing?
>
> regards,
>
> Geoff
>
More information about the use-livecode
mailing list