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

2 conditional

Explorer ,
Dec 01, 2006 Dec 01, 2006

Copy link to clipboard

Copied

I need to check for a minimum of two condition

<cfif IsDefined ("MyString") and MyString NEQ "ABC" OR IsDefined ("MyString") and MyString NEQ "CBA">
Do something
</cfif>
It should evaluate both and If one or the other match then criterias the it does not display the message "Do Something"


Is is obviousely not working, what would be the work around?

many thanks
TOPICS
Advanced techniques

Views

443

Translate

Translate

Report

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 ,
Dec 01, 2006 Dec 01, 2006

Copy link to clipboard

Copied

TommyMTL wrote:
> I need to check for a minimum of two condition
>
> <cfif IsDefined ("MyString") and MyString NEQ "ABC" OR IsDefined ("MyString")
> and MyString NEQ "CBA">
> Do something
> </cfif>


<cfif IsDefined("MyString") AND (MyString NEQ "ABC" AND MyString NEQ "CBA")>
Do something
</cfif>

Votes

Translate

Translate

Report

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 ,
Dec 01, 2006 Dec 01, 2006

Copy link to clipboard

Copied

You need nested cfif tags. The outer one checks for isDefined and the inner one checks the value of the string. Otherwise it will crash if the variable is not defined.

Votes

Translate

Translate

Report

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
Explorer ,
Dec 01, 2006 Dec 01, 2006

Copy link to clipboard

Copied

<cfif IsDefined("MyString") AND (MyString NEQ "ABC" AND MyString NEQ "CBA")>
Do something
</cfif>

In this example,
MyString must be defind, must not equal "ABC" and must not equal "CBA"
Shouls it not cointain an OR somewhere?
What I need is something that will do

"ABC" OR "CBA"

thanks

Votes

Translate

Translate

Report

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 ,
Dec 01, 2006 Dec 01, 2006

Copy link to clipboard

Copied

TommyMTL wrote:
> <cfif IsDefined("MyString") AND (MyString NEQ "ABC" AND MyString NEQ "CBA")>
> Do something
> </cfif>
>
> In this example,
> MyString must be defind, must not equal "ABC" and must not equal "CBA"

you just said it yourself...AND

> Shouls it not cointain an OR somewhere?
> What I need is something that will do
>
> "ABC" OR "CBA"

then you'll get both, ABC will not equal CBA & CBA will not equal ABC.

Votes

Translate

Translate

Report

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 ,
Dec 01, 2006 Dec 01, 2006

Copy link to clipboard

Copied

Dan Bracuk wrote:
> You need nested cfif tags. The outer one checks for isDefined and the inner
> one checks the value of the string. Otherwise it will crash if the variable
> is not defined.

not anymore, cf has had boolean short circuiting for a couple of versions.

Votes

Translate

Translate

Report

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 ,
Dec 01, 2006 Dec 01, 2006

Copy link to clipboard

Copied

LATEST
quote:

Originally posted by: Newsgroup User
Dan Bracuk wrote:
> You need nested cfif tags. The outer one checks for isDefined and the inner
> one checks the value of the string. Otherwise it will crash if the variable
> is not defined.
not anymore, cf has had boolean short circuiting for a couple of versions.


Well whaddya know?

Votes

Translate

Translate

Report

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
Documentation