[thelist] RE: (answer) Randomizing Question

Raymond K. Camden rcamden at allaire.com
Thu Nov 30 07:19:28 CST 2000


I've never heard this (the part about the memory leaks), and I don't believe
it to be true, if it were, then we would say it's a bad idea to do:

<CFSET Welcome = "Good morning, bob, I've hated you for #RandRage(1,300)#
days.">

as far as I know, there is nothing wrong with that.

That being said, what he did -was- bad form. Since he wasn't using the
values in a function, he should do as you say,

<CFSET RNUM1 = RandRange(1,289)>

p.s. Jeff, I'd love to see where you read that using functions in strings
could lead to memory leaks. Do you have a URL?

=======================================================================
Raymond Camden, Principal Spectra Compliance Engineer for Allaire

Email   : jedimaster at allaire.com
ICQ UIN : 3679482

"My ally is the Force, and a powerful ally it is." - Yoda


> -----Original Message-----
> From: thelist-admin at lists.evolt.org
> [mailto:thelist-admin at lists.evolt.org]On Behalf Of jeff
> Sent: Thursday, November 30, 2000 12:51 AM
> To: thelist at lists.evolt.org
> Subject: RE: [thelist] RE: (answer) Randomizing Question
>
>
> 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
>
>
> ---------------------------------------
> For unsubscribe and other options, including
> the Tip Harvester and archive of TheList go to:
> http://lists.evolt.org Workers of the Web, evolt !





More information about the thelist mailing list