Solved

Nested IIF() functions

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SCCM vs Windows server 5 87
Help with a redirect in web.config file 8 65
WebSite Direction 1 63
move expression web site to a new server 13 77
Turn A Profile Picture Into A Cartoon Using Photoshop And Illustrator This tutorial will teach you how to make a cartoon style image out of a regular picture. I have tried to keep the tutorial as simple as possible. I used Adobe CS4 for this tuto…
This guide will walk you through the essential considerations and tech stack for building scalable websites. Know how to grow your business the smart way!
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…
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…

726 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