[thelist] RE: (answer) Randomizing Question

jeff jeff at members.evolt.org
Wed Nov 29 23:52:01 CST 2000


palyne,

:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: From: Palyne Gaenir
:
:   <CFSET RNUM1 = "#RandRange(1,289)#">
:   <CFSET RNUM2 = "(#RNUM1# * #RandRange(6,3964)#)">
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

fwiw, i thought i'd mention that you should clean up your cf code a bit.  i
don't know which version of cf server you're using this on, but some reading
i've done recently on v4.5+ is that it's pickier about syntax and
unnecessarily hashing variables and functions has been connected to memory
leaks.

so, the above code could be reduced to:

<cfset rnum1 = RandRange(1, 289)>
<cfset rnum2 = "(" & rnum1 " * " & RandRange(6, 3964) & ")">

however, if you intend to actually compute the value of rnum2 before using
it in your ORDER BY statement, then the <cfset> for rnum2 should look like
this:

<cfset rnum2 = rnum1 * RandRange(6, 3964)>

this will the same results as far as the application is concerned with the
added benefit of increased readability.

good luck,

.jeff

name://jeff.howden
game://web.development
http://www.evolt.org/
mailto:jeff at members.evolt.org





More information about the thelist mailing list