> Still, however, I am confused about your solution.  When I run it (and the
> ListFindNoCase version), it doesn't work, but the FindNoCase version does.
> I'm not sure why.  In any case, what is the inconsistency in results that
> you mention with FindNoCase?  I'd just like to know so that I avoid future
> pitfalls.
>
OK.....  inconsistent results.....

<cfset DirectoryList = "Documents and
Settings,inetpub,document,temp,winnt,">

Take this string/list above.   If I do a FindNoCase or CONTAINS on this
string for "document" there are two places that "document" exists.  The
first being in "Documents and Settings" and the second actually being
"document".

If I'm looping through this list looking for specifically "document", then
CONTAINS will return true on "Documents and Setting" (I think its case
insensitive, but you get the point) and FindNoCase will return an index
greater than 0.  This would be a false positive for your condition.   In
this instance its quiet obvious whats happening, but imagine a situation
where both the DirectoryList and the string you are checking for is
dynamically generated.......

If you use ListFindNoCase, then you will get only exact case insensitive
matches.

Am I making any sense what so ever?? :o)

Anyway, here's a bit of code I chucked together a few minutes ago to
demostrate this.

<cfset strOmit = "Documents and Settings,inetpub,temp,winnt,">
<cfdirectory action="LIST" directory="c:\" name="myDirectoryList" sort="type
ASC, name ASC">

<cfloop query="myDirectoryList">
 <strong><cfoutput>#myDirectoryList.name#</cfoutput></strong>
 <cfif IsDefined("variables.strOmit") AND
ListFindNoCase(strOmit,myDirectoryList.name)>
  LISTFIND Omit this Directory -
 <cfelse>
  LISTFIND Full Details -
 </cfif>
 <cfif IsDefined("variables.strOmit") AND strOmit CONTAINS
myDirectoryList.name>
  CONTAINS Omit this Directory <BR>
 <cfelse>
  CONTAINS Full Details <BR>
 </cfif>
</cfloop>

To see this working you must have a folder called "document" in "c:\".  You
should see that "document" has full details in the ListFindNoCase condition,
but is omitted in the CONTAINS condition.

Something to watch for with list comparisons:
<cfset strOmit = "Documents and Settings, inetpub, temp, winnt">
is not the same as :
<cfset strOmit = "Documents and Settings,inetpub,temp,winnt">

in the first instance inetpub now has a space attached to the front of it,
as do temp and winnt.  Unless you tell the ListFind that the delimiter is ",
" (comma space) rather than just "," (comma) your comparison to "inetpub"
(no spaces) will fail.

I hope that all makes some kind of sense and has help you work out why your
code isn't working.

Regards

Stephen


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm

Reply via email to