If you are going to use a variable that doesn't exist then using this
method will cause you issues as cf will still try to evaluate both sides of
it even if false.

There are ways round it using nested evaluate and de statements, but
frankly it just becomes messy and unreadable, I used to do this myself.
You are better off just using cfif or switch statement instead.


On Tue, Feb 3, 2015 at 19:32 PM, Mosh Teitelbaum <mosh.teitelb...@evoch.com>
wrote:


All:

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?

Thanks.

--
Mosh Teitelbaum





~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:360048
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to