> I've run into a problem that I could use some new eyes on... I have a 
> function inside a CFC that accepts a
> query (importData) and a series of indicators (nicknameInd) that indicate if 
> the value from the query should
> be used (indicator = 1) or not (indicator = 0).  In the below code, the first 
> argument in the IIF() function
> evaluates to false (both conditions are false) so only the third argument, 
> De(""), should be evaluated. However,
> for some reason, both the second and third arguments are being evaluated and 
> I'm getting an error message
> that "Element NICKNAME is undefined in IMPORTDATA." Because 
> importData.nickname is not defined.
>
> <cfset variables.nickname = Iif( (arguments.nicknameInd NEQ 0) AND 
> (IsDefined("importData.nickname")),
> De(importData.Nickname), De(""))>
>
> I've replaced both the second and third arguments with debugging code that 
> showed that they are both being
> evaluated, regardless of the condition in the first argument.  Not sure why 
> that is though given that they're
> both wrapped in DE() functions.
>
> Any suggestions?

The word "evaluated" here, I don't think it means what you think it means.

Whenever you have a CF statement, the entire statement is evaluated.
So, if you have something like this:

function(variable)

CF is going to verify that the variable exists, because you're referring to it.

That's what's happening here. Just because you're using the DE()
function doesn't mean that CF isn't going to evaluate
importData.nickname at runtime to verify that there's actually
something called importData.nickname in case it needs to reference
that value.

Dave Watts, CTO, Fig Leaf Software
1-202-527-9569
http://www.figleaf.com/
http://training.figleaf.com/

Fig Leaf Software is a Service-Disabled Veteran-Owned Small Business
(SDVOSB) on GSA Schedule, and provides the highest caliber vendor-
authorized instruction at our training centers, online, or onsite.

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

Reply via email to