Since it's already its own function, why not just use it like so...

<cfoutput>
 #RandRange(1, 10)#<br />
 #RandRange(1, 10)#<br />
 #RandRange(1, 10)#<br />
</cfoutput>

-or-

<cfset end = 3>

<cfloop from="1" to="#end#" index="i">
 #RandRange(1, 10)#<br />
</cfloop>

Both produce the same results... 3 random numbers. The only disadvantage is
that you won't know what those numbers were for later use unless you set
them to variables like you were doing...

<cfset var1 = RandRange(1, 10)>
<cfset var2 = RandRange(1, 10)>
<cfset var3 = RandRange(1, 10)>

<cfoutput>
#var1#<br />
#var3#<br />
#var2#<br />
</cfoutput>

-or again in a loop-

<cfset end = 3>
<cfloop from="1" to="#end#" index="i">
 <cfset "var#i#" = RandRange(1, 10)>
</cfloop>

<cfoutput>
 <cfloop from="1" to="#end#" index="i">
  #variables["var#i#"]#<br />
 </cfloop>
</cfoutput>


-----Original Message-----
From: Chris McCarthy [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 31, 2005 7:35 PM
To: CF-Talk
Subject: Re: Question on randomizing multiple times on the same page

>You can reseed the random number generator with the Randomize() function, 
>but that may not be your problem.
>
><CFSET random_number=RandRange(1, 10)>
><CFOUTPUT>
>#random_number#
>#random_number#
>#random_number#
></CFOUTPUT>
>
>Here you set a single variable to a random value, then you output it on 
>the page three times.  The variable's value isn't going to change each 
>time.  If you made "random_numer" a user defined function, then it may do 
>what you're looking for.  Or create three different variables and set each 
>one using RandRange().
>
>
>----- Original Message ----- 
>From: "Chris McCarthy" <[EMAIL PROTECTED]>
>To: "CF-Talk" <[email protected]>
>Sent: Thursday, March 31, 2005 5:10 PM
>Subject: Question on randomizing multiple times on the same page
>
>
>>

Thanks Jim, I'll try the UDF approach :).  Just wanted to make sure I wasn't
missing something basic.

-Chris



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:201137
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to