I've got one. :)
function call(fn,args) {
var x = 0; var stArgs = "";
for (x = 1; x lte arraylen(args); x = x + 1) {
stArgs = listappend(stArgs,"args[#x#]");
} return evaluate("#fn#(#stArgs#)");
}
I'll admit it's an obscure example -- and at the moment actually the
only instance I can think of in my own code where I'm using evaluate()
-- I think there are one or two others, but certainly not many. This
function calls another function using an arbitrary array of arguments.
Useful for automating certain tasks, like the cf_jso library in the
onTap framework, which just creates versions of the functions in the
cf_dom library which are wrapped with <script>//<![CDATA[ ...
//]]></script> tags.
> Well, I'd say almost nothing forces you to use Evaluate.
> Just like
> nothing forces you to use addition. However, that being
> said, I can
> think of one case where you _almost_ need evalute... and
> that's
> valueList. You must pass in the query name and column
> name, and it
> can't be dynamic. Strictly speaking though, evaluate isn't
> necessary,
> as you can do the same thing with a loop and bracket
> notation.
> On Thu, 24 Mar 2005 12:35:01 -0800, Ian Skinner
> <[EMAIL PROTECTED]> wrote:
>> I just wanted to add that for the purpose of "evaluate()"
>> bracket notation and dot notation are pretty much equal.
>> Neither of them are using an evaluate function.
>>
>> I believe the spirit of the challenge, as Jared opened
>> with, was to show a situation were evaluate() was the
>> only way to achieve the correct result.
>>
>> I have yet to run into such a situation in my own coding.
>>
>> --------------
>> Ian Skinner
>> Web Programmer
>> BloodSource
>> www.BloodSource.org
>> Sacramento, CA
>>
>> "C code. C code run. Run code run. Please!"
>> - Cynthia Dunning
>>
>> ....-----Original Message-----
>> ....From: Jared Rypka-Hauer - CMG, LLC
>> [mailto:[EMAIL PROTECTED]
>> ....Sent: Thursday, March 24, 2005 12:24 PM
>> ....To: CF-Talk
>> ....Subject: Re: eval
>> ....
>> ....Actually, I believe the challenge was to show a
>> situation wherein
>> ....Evaluate() was an absolutely necessary tool.
>> ....
>> ....The brackets came into the picture as a solution to
>> avoid using
>> ....Evaluate(). Things that can now be expressed in
>> bracketed expressions
>> ....used to demand the Evaluate() function to resolve
>> their values... cuz
>> ....when you think about it, structVar[myVar] really IS a
>> double
>> ....evaluation... first myVar, then
>> structVar['evaluated-value-of-myVar'].
>> ....
>> ....Actually there's a bunch of places where brackets
>> won't work.
>> ....Assinging a stored procedure resultset directly into
>> a struct element,
>> ....for instance:
>> ....
>> ....<cfprocresult name="myProcResults['rs1']" />
>> ....
>> ....won't work, at least on MX 6.1 whereas:
>> ....
>> ....<cfprocresult name="myProcResults.rs1" />
>> ....
>> ....works just fine!
>> ....
>> ....So there's a few places where it won't work...
>> ....
>> ....I've been accused of overusing brackets lately, but
>> I've discovered
>> ....that my code is so drastically more readable because
>> of the
>> ....color-coding differences between quoted and unquoted
>> strings, that I'm
>> ....making infinitely fewer mistakes and spenting 10% of
>> the
>> ....troubleshooting time I used to. Dots leave everything
>> the exact same
>> ....color, and I can't see the details... it's all a big
>> blob to mine
>> ....eyes. For me, even it means a bit more typing, having
>> error-free,
>> ....readable code is the big priority.
>> ....
>> ....Right, Sean? hehe
>> ....
>> ....Laterz,
>> ....J
>> ....
>> ....On Thu, 24 Mar 2005 18:35:29 -0000, Kerry
>> <[EMAIL PROTECTED]> wrote:
>> ....> Hi, I remember there was a discussion on one of
>> these lists about using
>> ....> brackets instead of eval and I think Sean
>> challenged anyone to show him
>> ....some
>> ....> code where brackets couldnt be used?
>> ....>
>> ....> erm, is this one?
>> ....>
>> ....> valuelist(qry[myvar])
>> ....>
>> ....> (i hope im wrong....)
>> ....>
>> ....>
>> ....
>> ....
>>
>>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking
application. Start tracking and documenting hours spent on a project or with a
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:199916
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