Flasher Archive

[Previous] [Next] - [Index] [Thread Index] - [Previous in Thread] [Next in Thread]


Subject: Re: FLASH: set variable randomly, numbers should only be taken once
From: Helen Triolo
Date: Wed, 12 Jul 2000 14:27:34 +0100

Hats off to you once again, Branden, for an efficient (and clever) way
to solve exactly the problem that was given. I stuck it in the database
(of course) and added a modification for doing the same to an ordinary
"array" (eg, var1-var5) too.

Regards,
Helen
---------------------------------------------------
helen triolo � http://i-technica.com � 301-424-6037
Flash Q&A archive � http://i-technica.com/flashlist

nadia wrote:

>>i need to set 5 variables (a,b,c,d,e) to random number out of 56, the thing is that
>>every number should only be taken once, how do i do that?

and Branden Hall answered:
>
> Set Variable: "numElements" = 5
> Set Variable: "maxVal" = "56"
> Set Variable: "outer" = 1
> Loop While (outer <= numElements)
> Set Variable: "duplicate" = true
> Loop While (duplicate = true)
> Set Variable: chr(ord("a")+outer-1) = random(maxVal)+1
> Set Variable: "duplicate" = false
> Set Variable: "inner" = 1
> Loop While (inner < outer and duplicate = false)
> If (eval(chr(ord("a")+inner-1)) =
> eval(chr(ord("a")+outer-1)) )
> Set Variable: "duplicate" = true
> End If
> Set Variable: "inner" = inner+1
> End Loop
> End Loop
> Trace (chr(ord("a")+outer-1)&":"&eval(chr(ord("a")+outer-1)) )
> Set Variable: "outer" = outer+1
> End Loop
>

flasher is generously supported by...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
flashforward2000 and the Flash(tm) Film Festival
July 24-26, 2000, NEW YORK CITY, Hammerstein Ballroom
www.flashforward2000.com
Produced by United Digital Artists and lynda.com
Sponsored by Macromedia, Adobe Systems, Fusion, Inc, AtomFilms,
shockwave.com and Electric Rain.
1.877.4.FLASH.4 or (1.805.640.6679 outside the US and Canada)
Register before June 30 and save $200!!-- www.flashforward2000.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe or change your list settings go to
http://www.chinwag.com/flasher or email helpatchinwag [dot] com


Replies
  RE: FLASH: set variable randomly, number, Branden Hall

[Previous] [Next] - [Index] [Thread Index] - [Next in Thread] [Previous in Thread]