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
Dave Watts wrote:
cfset variables.nickname = Iif( (arguments.nicknameInd NEQ 0) AND
(IsDefined(importData.nickname)),
De(importData.Nickname), De())
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
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
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
Thanks Russ (and Dave).
That's the route I ended up going to. Kind of annoying as I think the Iif()
method produces cleaner code (and I had already written it) but it is what it
is.
--
Mosh Teitelbaum
Russ Michaels wrote
If you are going to use a variable that doesn't exist then using this
cfset variables.nickname = Iif( (arguments.nicknameInd NEQ 0) AND
(IsDefined(importData.nickname)),
De(importData.Nickname), De())
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()
Well if you want to try it out then try using nested evaluate(de(''))
You can also achieve same using nested quotes like de('stuff') to avoid
evaluation,
But it just gets messy imho
Iif() has its uses for simple inline evaluations, such as select lists or
dynamic style classes but beyond that I
7 matches
Mail list logo