Iif() Evaluation Weirdness

2015-02-03 Thread Mosh Teitelbaum
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

RE: Iif() Evaluation Weirdness

2015-02-03 Thread Mosh Teitelbaum
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

Re: Iif() Evaluation Weirdness

2015-02-03 Thread Dave Watts
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

Re: Iif() Evaluation Weirdness

2015-02-03 Thread Russ Michaels
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

RE: Iif() Evaluation Weirdness

2015-02-03 Thread Mosh Teitelbaum
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

Re: Iif() Evaluation Weirdness

2015-02-03 Thread Dave Watts
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()

Re: Iif() Evaluation Weirdness

2015-02-03 Thread Russ Michaels
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