Thanks. I'm actually after the structvalue if it exists and a zero length
string if it doesn't. It looks like Rex has me sorted though. Thanks Dom.

On Wed, Sep 8, 2010 at 3:24 AM, Dominic Watson <
[email protected]> wrote:

>
> On a side note, if you're after an output of 'yes' or 'no', this may be
> cleaner:
>
> #YesNoFormat( StructKeyExists(x.classAssign, "#y#head") )#
>
> Dominic
>
>
> On 8 September 2010 02:30, Michael Grant <[email protected]> wrote:
> >
> > So I went back and read the docs for IIF. I haven't looked at them in
> years
> > and I'm shocked that I've used it for SOOOOO many years without really
> > knowing exactly how it worked. I would've first read about IIF pre
> version
> > 5. I can't even find the docs for it. Version 5's description is a little
> > vague. You learn something new every day I guess. That's awesome. Thanks
> > again Rex.
> >
> >
> > On Tue, Sep 7, 2010 at 8:49 PM, Michael Grant <[email protected]> wrote:
> >
> >> Wow. I had no idea you could wrap DE in Evaluate. Did you come figure
> this
> >> out through trial and error or have I just never read it?
> >>
> >> Thanks for the post rex.
> >>
> >>
> >> On Tue, Sep 7, 2010 at 8:34 PM, rex <[email protected]> wrote:
> >>
> >>>
> >>> A lot of people get DE() wrong.
> >>>
> >>> IIF does not short-circuit
> >>> (http://en.wikipedia.org/wiki/Short-circuit_evaluation), meaning that
> >>> your DE() gets evaluated even if the condition is FALSE.  So, this will
> >>> break:
> >>>    #iif(false, notFalse, false)#
> >>> since notFalse does not exist.  Same here:
> >>>    #iif(true, true, fols)#
> >>> since fols does not exist.  And finally your code:
> >>>    #iif(false, DE(x.classAssign["#y#head"]), DE(''))#
> >>> breaks since x.classAssign["NAMEhead"] does not exist.
> >>>
> >>> DE evaluates a STRING parameter and finds double-quotes.  If you pass
> in
> >>> a variable, it looks for the value of that variable.  Since you are
> >>> passing x.classAssign["#y#head"], it looks for
> x.classAssign["NAMEhead"]
> >>> and breaks.
> >>>
> >>> This will work: evaluate(DE("x.classAssign['#y#head']"))  - notice the
> >>> single-quotes surrounding #y#head!  This is because we don't want DE to
> >>> escape this, so we don't want to wrap it around double-quotes!
> >>>
> >>> Here is the code (I used "no value" instead of "", but it's still the
> >>> same code that you use):
> >>>
> >>> <cfset x.classAssign = {
> >>>    NameHead = "this head",
> >>>    NoNameHead = "that head"
> >>> } />
> >>> <cfoutput>
> >>>    <cfset y = "Name" />
> >>>     #iif(StructKeyExists(x.classAssign,"#y#head"),
> >>> evaluate(DE("x.classAssign['#y#head']")), DE("no value"))#<hr />
> >>>    <cfset y = "NoExist" />
> >>>     #iif(StructKeyExists(x.classAssign,"#y#head"),
> >>> evaluate(DE("x.classAssign['#y#head']")), DE("no value"))#<hr />
> >>>
> >>>    <cfset Y = 'Any' />
> >>>    See how these two differ: <br />
> >>>    #DE("x.classAssign['#y#head']")#<br />
> >>>    #DE('x.classAssign["#y#head"]')#
> >>> </cfoutput>
> >>>
> >>> Michael Grant wrote:
> >>> > HA! So I'm not the only one!
> >>> > So I thought DE meant "Delay Evaluation" as in "Don't evaluate what's
> in
> >>> > these little brackets this until you've satisfied the IIF condition."
> >>> >
> >>> >
> >>>
> >>>
> >
> >
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:336894
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to