Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Conditional Expression in ColdFusion

New Here ,
Jan 18, 2010 Jan 18, 2010

Use the function iif().  There is no operator or expression syntax.

This was remarkably hard to find out.  There seem to be a lot of people who don't know what one is.  Also, the term gets used to refer to the condition that is evaluated for a case statement.  The CF case statement is a <cfswitch> I believe.  And it seems to be in an error message that is frequently encountered in an attempt to write a query on a query.

So for experts who know languages and what a conditional expression is, but might be coming to ColdFusion recently like me, this might hopefully get indexed and turn up in searches.

No reply required.

TOPICS
Getting started
1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 18, 2010 Jan 18, 2010

Huh?

--

Adam

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 18, 2010 Jan 18, 2010
No reply required.

Nah, you're asking for it.

This was remarkably hard to find out.  There seem to be a lot of people who don't know what one is.

Like a decent woman or good wine? It's all about where you look, mate, and the luck o' the draw.

The CF case statement is a <cfswitch> I believe.

The CF case statement is a <cfcase>.

And it seems to be in an error message that is frequently encountered in an attempt to write a query on a query.

I'll leave that one to them experts like you. When I tried to open it, my spanner broke

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 19, 2010 Jan 19, 2010

There are many of us who work in multiple environments. I know

there are lots of deeply expert x/html, css, php, coldfusion, etc

people out there, but I sure wish that there was more in the way of

references that used the terminology of programming languages and

efficiently provided pointers to the constructs needed that don't

begin with "for example" and then proceed with lots of "why you would

want to write a program" and "how to get started writing your own web

site with ". I also wish there were a language

reference with a formal syntax for some of these.

Perhaps I criticize unfairly. I have actually embarked upon simply

reading the w3c definitions, but I don't find such a thing for php,

coldfusion, et al.

Thanks for the reply, and correction.

Turns out, too, that iif() is not quite what it appears. So I've

abandoned conditional expressions and just write flow of control ...

g'day

Ben

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 19, 2010 Jan 19, 2010

I'm sure you have a good point in your initial post.  The problem is... I have no idea what it is you're trying to say.  Which - given what I think you're trying to say - seems slightly ironic to me.

So, like, what're you trying to say in your first post?

--

Adam

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 19, 2010 Jan 19, 2010

Hi,

Sorry if it's obtuse. When an experienced programmer comes to a new

language, he/she needs a reference to the particular syntax. We

don't need definitions by example, long paragraphs about why you

would want to do something, or tutorials about how to do this or

that, which is what the majority of stuff out there is these days.

Searches on Google and in Adobe docs produced very little of use when

I went looking for the conditional expression syntax in ColdFusion.

(I'm cleaning up some very messy and completely undocumented code so

I can figure out how to safely make some mods to improve the

usability.) Turns out there's not one. And iif() is problematic.

I just wanted to post something that Google and forum searches might

hit for people like me later who were looking for whether CF offered

a conditional expression syntax. "There's not one" is a perfectly

usable answer, but I couldn't even find that...

Paul

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 19, 2010 Jan 19, 2010

There is also the ternary operation "?:".  At least with CF9.

You're specifically after an expression-ready one, not just statements such as <cfif> or if(), yeah?


I dunno how you searched, but I went to http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/index.html, had a shufti in the CFML reference but didn't immediately see anything obvious,so tried the "Developing..." section instead.  Within there there's "The CFML Programming Language" > "Using Expressions and Number Signs" > "Expressions", and on that page the Ternary operator.

I don't think that's such a far-fetched search path to use?  And it was pretty easy to find.

I did try searching for "expressions", but that yielded too mnay results, so I abandoned that immediately.  Searching for "conditional expressions" yields iif() as the only match, and that's a pretty reasonable way of finding an answer too.  iif() has been implemented very clumsily though, I agree there.

I'm not sure it is that hard really, is it?

--

Adam

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 19, 2010 Jan 19, 2010
LATEST

I think that might be new in CF9. I did the search you describe for

MX7, which is what the client is running.

Apparently, had I known to search on "ternary operator" I would have

hit a gold mine in Wiki. Of course, the conditional expression is

only one instance of a ternary operator, but the phrases get

incorrectly used as if interchangeable.

http://en.wikipedia.org/wiki/Ternary_operation

So please feel free to write me off as idle, stupid, grumpy, or

whatever you like. I'm done with this whole issue. I put up a post

that I hoped would get a hit to help others behind me, that's all.

Paul

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources