Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Nested IIF() functions

Posted on 2003-11-14
4
Medium Priority
?
1,141 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 200 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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
The purpose of this video is to demonstrate how to make a WordPress Site faster and smaller in size by cleaning up the database. This will be demonstrated using a Windows 8 PC. Plugin WP Optimize will be used. Go to your WordPress login page. T…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…
Suggested Courses

610 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