Random generator exercise
Ken Ray
kray at sonsothunder.com
Wed Jan 22 08:33:00 EST 2003
Nate,
Why don't you use "repeat with x = 1 to valrn" - this way you don't have to
do an "until", or increment x; it happens automatically.
Ken Ray
Sons of Thunder Software
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/
----- Original Message -----
From: "ncouch" <ncouch at mail.airmail.net>
To: <use-revolution at lists.runrev.com>
Sent: Wednesday, January 22, 2003 12:05 PM
Subject: Random generator exercise
> I am in a bit of a quandry trying to tweak this script. It's main
function
> is to generate a random sequence of from 1-9 alpha and numerical
characters.
> The main problem I am having is updating the global value of x after each
> run of the repeat loop.
>
> As it stands right now it keeps resetting the value back to "1" after each
> loop. I understand why it does this, but don't understand why I can't
reset
> the value after each run. Anyone have any ideas on how I might do this.
>
> Here is the script so far:
>
> =================================================
>
> on MouseUp
> -- setting things up
> put empty into field "random"
> put empty into field "rn"
> put empty into field "valx"
> ask "How many characters do you want? (# between 1 and 9)"
> put it into field "valrn"
> put it into valrn
> put 1 into x
>
> -- generating the random sequence
> repeat until x=(valrn+1)
> put random(2) into rc
> put rc into line x of field "rn"
>
> if rc=1 then
> ralpha -- an alpha character
> else rnum -- a number
>
> add 1 to x
> end repeat
> end MouseUp
>
> on ralpha
> global x
> put random(26) into rn
> get char rn of field "alpha"
> put it into char x of field "random"
> end ralpha
>
> on rnum
> global x
> put random(9) into rn
> put rn into char x of field "random"
> end rnum
>
> =================================================
>
> Cheers,
>
> Nate
>
> _______________________________________________
> 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