Solved

Nested IIF() functions

Posted on 2003-11-14
4
1,039 Views
Last Modified: 2013-12-20
I get an "Undefined variable" error when ColdFusion tries to evaluate this nested iif() expression:

#iif(scheduled_to_run IS "Y", de("Yes"), iif(scheduled_to_run IS "N", de("No"), scheduled_to_run))#

I've had to settle for this expression that works:

#iif(scheduled_to_run IS "Y", de("Yes"), de("No"))#

...but it doesn't display the value of scheduled_to_run if it as an unexpected value (neither "N" or "Y").

I don't want to use <cfif>.  I'm just stuborn.

0
Comment
Question by:CarlsonCo
  • 2
4 Comments
 
LVL 12

Expert Comment

by:jyokum
ID: 9749637
an if statement is going to be better than using iif

I realize you said you don't want to use <cfif> but here goes anyways...

<cfscript>
if(scheduled_to_run eq 'Y') result = 'Yes';
elseif(schedule_to_run eq 'N') result = 'No';
else result = scheduled_to_run;
</cfscript>

<cfoutput>#result#</cfoutput>
0
 

Author Comment

by:CarlsonCo
ID: 9749910
I'm more interested in finding out why the ColdFusion expression evaluator is puking on this.
0
 
LVL 15

Accepted Solution

by:
danrosenthal earned 50 total points
ID: 9750542
Interesting problem. Not exactly sure why, but having multiple DE() works:

#iif(scheduled_to_run IS "Y", de("Yes"), iif(scheduled_to_run IS "N", de(de("No")), de(de(scheduled_to_run))))#

Just for curiousity I went another level in and found I needed 3 DE() statements to get the values out:
#iif(scheduled_to_run IS "Y", de("Yes"), iif(scheduled_to_run IS "N", de(de("No")), iif(scheduled_to_run IS "M",de(de(de("Maybe"))),de(de(de(scheduled_to_run))))))#


Very odd.
0
 

Author Comment

by:CarlsonCo
ID: 9750647
Dan the man,
LOL...that's too hilarious!  I knew there was a way around their funky expression evaluator.

It's definately not C style expressions.  But I understand their expression evaluator much better now.

Thanks a lot!
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Objective of This Article In 1990’s, when I was a budding software professional, I had a lot of confusion about which stream or technology, I had to choose to build my career. In those days, I had lot of confusion like whether to choose System so…
The purpose of this video is to demonstrate how to update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now