Solved

Nested IIF() functions

Posted on 2003-11-14
4
1,092 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
I starting with php 12 137
Add server behaviors to Dreamweaver CC 2015 2 185
How code a 301 redirect for folder files -> 1 file 2 58
Adding multiple JVM environments to RedHat 6 7 48
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
The purpose of this video is to demonstrate how to automatically show related posts at the bottom of a blog post in WordPress. This will be demonstrated using a Windows 8 PC. Plugin “Yet Another Related Posts Plugin” will be used. Go to your…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…

831 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