Skip to main content
Known Participant
March 18, 2011
Question

A better expression?

  • March 18, 2011
  • 5 replies
  • 1182 views

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")>

This topic has been closed for replies.

5 replies

Participating Frequently
April 21, 2011

The below is also one of the possible way..

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

Fernis
Inspiring
April 21, 2011

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

Inspiring
April 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...

Fernis
Inspiring
April 21, 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

Inspiring
April 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.

Fernis
Inspiring
April 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

Inspiring
March 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?

Owainnorth
Inspiring
March 18, 2011

Where'd you hear that?