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

A better expression?

Community Beginner ,
Mar 18, 2011 Mar 18, 2011

I heard that there is a better way than doing this, can anyone tell me? Thanks you!

<CFIF (st_addr["City"] NEQ "Ohio") OR (st_addrs["City"] NEQ "San Jose")>

TOPICS
Getting started
1.0K
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
Guide ,
Mar 18, 2011 Mar 18, 2011

Where'd you hear that?

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 ,
Mar 18, 2011 Mar 18, 2011

Hard to say anything without some context.  What is st_addr?  Where does that line show up in your code?  Is there a cfelseif or cfelse tag as well?

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
Enthusiast ,
Apr 19, 2011 Apr 19, 2011

If st_addr and st_addrs are meant to be the same, i.e. there's a typo in the example, ... then in your case,

<CFIF (st_addrs["City"] NEQ "Ohio") OR (st_addrs["City"] NEQ "San Jose")>

is just without a point, since it will always produce a TRUE result with any values of st_addrs["City"].

The value is always either not "ohio" or not "san jose".

-Fernis

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
Participant ,
Apr 20, 2011 Apr 20, 2011

<cfif "Ohio,San Jose" Does Not Contain st_addrs["City"]>

Does it with a single compare and is very readable; if that's what your after that is...

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
Enthusiast ,
Apr 20, 2011 Apr 20, 2011

> <cfif "Ohio,San Jose" Does Not Contain st_addrs["City"]>

> Does it with a single compare and is very readable; if that's what your after that is...

This would not work properly, since it does a string comparison, not a list item comparison.

<cfif "New York,Boston" does not contain "York"> would be a true condition.

Use NOT ListContainsNoCase() instead.

-Fernis

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
Participant ,
Apr 21, 2011 Apr 21, 2011

Yes, it's  true that the list does not contain the value. OP seems to have lost interest, with info provided this returns desired result.

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
Explorer ,
Apr 20, 2011 Apr 20, 2011

The below is also one of the possible way..

<cfset cityList="Ohio,San Jose">
<cfif ListFindNoCase(cityList,st_addrs["City"])>
................
................
................
</cfif>

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
Enthusiast ,
Apr 21, 2011 Apr 21, 2011
LATEST

Amiya,

Oh yes, definitely prefer ListFindNoCase instead of ListContains, that was what I meant, but misthought it somehow 🙂 Otherwise I would've just corrected a wrong example with another wrong example

-Fernis

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