iif and evaluate and de have enough of a performance hit that I NEVER use
them.

Since they changed the scopes around (everything is in a structure now) a
few versions ago you really no longer need them, at least I haven't seen
anything that really required the.

> -----Original Message-----
> From: Josh Nathanson [mailto:[EMAIL PROTECTED]
> Sent: Friday, July 21, 2006 4:48 PM
> To: CF-Talk
> Subject: Re: am I understanding correctly?
> 
> Hi Jacob,
> 
> Yup, I get the part about condition true, return 2nd parameter, else
> return
> 3rd parameter, but in this:
> <cfset temp = evaluate("getCust.#i#")>
> 
> It seems to me that iif actually does something like this:
> <cfset temp = evaluate(DE("getCust.#i#"))>
> 
> But it only "DE's" if the pound signs are there, so that the #i# doesn't
> get
> evaluated when the page is first compiled -- it "waits" until the cfloop
> starts looping.  If there are no pound signs, you have to explicitly put
> DE("") for example, otherwise you get a string index error.
> 
> Loathe -- what sort of performance hit are we talking about?  I like the
> cleanliness of doing it in one line, but if it's a big performance hit I
> guess it's not worth it.
> 
> -- Josh
> 
> 
> 
> ----- Original Message -----
> From: "Munson, Jacob" <[EMAIL PROTECTED]>
> To: "CF-Talk" <[email protected]>
> Sent: Friday, July 21, 2006 1:22 PM
> Subject: RE: am I understanding correctly?
> 
> 
> > Here's how I understand iif:  If the condition is true, return the 2nd
> > parameter, otherwise return the 3rd.
> >
> > So in your example, if (didquery and didfind) returns true, the code
> > will evaluate getCust.#i#.  Otherwise it will evaluate DE("").
> >
> > iif is basically just a shorter cfif statement, using your example iif,
> > this would do the same thing:
> > <cfif didquery and didfind>
> > <cfset temp = evaluate("getCust.#i#")>
> > <cfelse>
> > <cfset temp = "">
> > </cfif>
> >
> > But that takes a lot more code.
> >
> >> -----Original Message-----
> >> From: Josh Nathanson [mailto:[EMAIL PROTECTED]
> >> Sent: Friday, July 21, 2006 1:41 PM
> >>
> >> I have some code that loops over a list of fields to cfparam some
> >> attributes.  The idea is, if the query (getCust) returns a
> >> record, set the
> >> attribute to the query.column value;  if no record, set the
> >> attribute to
> >> null.  After some hacking around I got it to work as desired,
> >> but I don't
> >> quite understand how.
> >>
> >> <cfset fieldlist =
> >> "Customer_ID,FirstName,LastName,Email,Address1,Address2,City,S
> >> tate,State2,Zip,Country,Phone">
> >> <cfloop list="#fieldlist#" index="i">
> >>  <cfset temp = iif(didquery and didfind, "getCust.#i#", DE(""))>
> >>  <cfparam name="attributes.#i#" default="#temp#">
> >> </cfloop>
> >>
> >> What I don't get is how iif works.  It seems to do the following:
> >> - Doesn't evaluate "getCust.#i#" when the page is compiled
> >> - Assuming the iif conditional evaluates true, when the list
> >> is looped,
> >> first evaluates just the "#i#" in "getCust.#i#" to return the
> >> proper field
> >> name, then evaluates the variable "getCust.FirstName" (for
> >> example) to
> >> return the correct value.  So there is sort of a double
> >> evaluation going on.
> >>
> >> Am I understanding iif correctly or does someone have a
> >> better explanation
> >> as to how it works.  The docs are kind of hard to fathom.
> >
> > This transmission may contain information that is privileged,
> confidential
> > and/or exempt from disclosure under applicable law. If you are not the
> > intended recipient, you are hereby notified that any disclosure,
> copying,
> > distribution, or use of the information contained herein (including any
> > reliance thereon) is STRICTLY PROHIBITED. If you received this
> > transmission in error, please immediately contact the sender and destroy
> > the material in its entirety, whether in electronic or hard copy format.
> > Thank you. A1.
> >
> >
> >
> >
> 
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/cf_lists/message.cfm/forumid:4/messageid:247367
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to