Its like Comparators in Java. Its the "difference" that is being returned not the 
Truth of a match. Thus if they match there is ZERO difference not a boolean true 
otherwise you'd use equals right ?

Its not inuitive but it sort of makes sense is you think that you are performing a 
comparison and not a match.

Russell
-----Original Message-----
From: Stephen Moretti [mailto:stephen@;cfmaster.co.uk]
Sent: 18 October 2002 12:30
To: [EMAIL PROTECTED]
Subject: Re: [ cf-dev ] CF "Feature"


I think the confusion is that compare and comparenocase actually do
something a little strange....

You would think that str1 matches str2 or it doesn't.
In this case, you have compare(str1, str2)  : if the two string are the same
then the result is TRUE!  if not then the result is FALSE!  (1/0, Yes/No
whatever boolean response your prefer...

What is actually happening (and I don't really understand how this works) is
:
    if string1 is less than string2 then you get a negative number.
    if string1 is equal to string2 then you get 0
    if string1 is greater than string2 then you get a positive number.

I'm not really sure how you can tell when comparing 2 strings whether one is
_greater_ than the other, but that is what the confusion is....

Stephen

----- Original Message -----
From: "Spike" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, October 18, 2002 12:05 PM
Subject: RE: [ cf-dev ] CF "Feature"


> I'm not sure I understand what you're getting at here.
>
> comparenocase(str1,str2) is designed to allow you to compare strings.
>
> It will return -1 if the first string is shorter than the second string,
> 1 if the first string is longer than the second string, and 0 if the
> strings are identical.
>
> Can you think of an alternative arrangement that would allow it to
> return something that would be evaluated to true if the strings are
> equal?
>
> Bearing in mind that any non-zero number will evaluate to true when used
> in a boolean comparison in CF.
>
> i.e.
> <cfif 100>
>   YUP!
> <cfelse>
>   NOPE!
> </cfif>
>
> Outputs YUP!
>
> Spike
>
>
> Stephen Milligan
> Team Macromedia - ColdFusion
> Co-author 'Reality Macromedia ColdFusion MX: Intranets and Content
> Management'
> http://spikefu.blogspot.com
>
> > -----Original Message-----
> > From: Kola Oyedeji [mailto:kola.oyedeji@;iclployalty.com]
> > Sent: 18 October 2002 12:49
> > To: [EMAIL PROTECTED]
> > Subject: RE: [ cf-dev ] CF "Feature"
> >
> >
> > Spike
> >
> > Just to add to that. It seems silly to me that 0 can evaluate
> > to false but then compareNoCase returns 0 if the strings
> > match (which could be regarded as true) so..
> >
> > <cfif compareNocase( string1, string2) >
> >
> > ...
> >
> > </cfif>
> >
> > Is slightly misleading as you would expect that if they
> > match, the if block will be executed but this is not the case
> > (assuming the strings are the same)
> >
> > Kola
> >
> > >> -----Original Message-----
> > >> From: Spike [mailto:spike@;prisma-it.com]
> > >> Sent: 18 October 2002 11:31
> > >> To: [EMAIL PROTECTED]
> > >> Subject: RE: [ cf-dev ] CF "Feature"
> > >>
> > >> erm...
> > >>
> > >> compareNocase() returns 0 (boolean false)if the strings
> > are identical
> > >> and returns -1 or 1 (boolean true) otherwise.
> > >>
> > >> It doesn't seem too silly to me to say that "Yes" isn't the same as
> > "1".
> > >>
> > >> Spike
> > >>
> > >> Stephen Milligan
> > >> Team Macromedia - ColdFusion
> > >> Co-author 'Reality Macromedia ColdFusion MX: Intranets and Content
> > >> Management' http://spikefu.blogspot.com
> > >>
> > >> > -----Original Message-----
> > >> > From: Rich Wild [mailto:r.wild@;e-mango.com]
> > >> > Sent: 18 October 2002 12:05
> > >> > To: '[EMAIL PROTECTED]'
> > >> > Subject: RE: [ cf-dev ] CF "Feature"
> > >> >
> > >> >
> > >> > it happens in MX as well, also with this code:
> > >> >
> > >> > <cfif comparenocase("yes", "1")>
> > >> > true
> > >> > <cfelse>
> > >> > false
> > >> > </cfif>
> > >> >
> > >> > which is just plain silly.
> > >> >
> > >> > as far as I know its always done this though.
> > >> >
> > >> > > -----Original Message-----
> > >> > > From: Matt Horn [mailto:matt.horn@;mediatelgroup.co.uk]
> > >> > > Sent: 18 October 2002 11:19
> > >> > > To: [EMAIL PROTECTED]
> > >> > > Subject: Re: [ cf-dev ] CF "Feature"
> > >> > >
> > >> > >
> > >> > > we use 5 at the moment
> > >> > >
> > >> > > and yes I did get the window solved
> > >> > >
> > >> > > made a workaround .. PPk told me you cant create an
> > empty window
> > >> > > object
> > >> > >
> > >> > >
> > >> > > At 11:19 18/10/02 +0100, you wrote:
> > >> > > >hmmmm scary....
> > >> > > >
> > >> > > >Is that an MX feature or a CF "all versions" feature?
> > >> > > >
> > >> > > >Stephen
> > >> > > >PS. Did you get your JS window object problem sorted?
> > >> > > >
> > >> > > >----- Original Message -----
> > >> > > >From: "Matt Horn" <[EMAIL PROTECTED]>
> > >> > > >To: <[EMAIL PROTECTED]>
> > >> > > >Sent: Friday, October 18, 2002 11:12 AM
> > >> > > >Subject: [ cf-dev ] CF "Feature"
> > >> > > >
> > >> > > >
> > >> > > > > Something of interest one of our developers found :
> > >> > > > >
> > >> > > > >
> > >> > > > >
> > >> > > --------------------------------------------------------------
> > >> > > ------------
> > >> > > >-------------
> > >> > > > > How do you think the following statement will be
> > >> > resolved: <cfset
> > >> > > > > var1 = "Yes">
> > >> > > > >
> > >> > > > > <cfif var1 EQ 1>
> > >> > > > >                  true
> > >> > > > > <cfelse>
> > >> > > > >                  false
> > >> > > > > </cfif>
> > >> > > > > You would think that it would return false (I certainly
> > >> > > did), instead it
> > >> > > > > returns true!
> > >> > > > > Cold Fusion does a (not so) clever boolean conversion on
> > >> > > the string "Yes"
> > >> > > > >
> > >> > > > > Even if you attempt to cast the 1 as a string "1" in
> > >> > the if: <cfif
> > >> > > > > var1 EQ "1">
> > >> > > > >                  true
> > >> > > > > <cfelse>
> > >> > > > >                  false
> > >> > > > > </cfif>
> > >> > > > > Still true!
> > >> > > > >
> > >> > > > > The only way to get around this is to do an extra check
> > >> > > of IsNumeric():
> > >> > > > > <cfif IsNumeric(var1) AND var1 EQ 1>
> > >> > > > >                  true
> > >> > > > > <cfelse>
> > >> > > > >                  false
> > >> > > > > </cfif>
> > >> > > > > Then you get false (hurray!).
> > >> > > > >
> > >> > > --------------------------------------------------------------
> > >> > > ------------
> > >> > > >----------------------------
> > >> > > > >
> > >> > > > > Matt Horn
> > >> > > > > Senior Web Applications Developer
> > >> > > > > MediaTel Group
> > >> > > > > 84-86 Regent Street
> > >> > > > > London
> > >> > > > > W1B 5AJ
> > >> > > > > Tel: +44(0)20 7439 7575
> > >> > > > > Fax: +44(0)20 7734 0940
> > >> > > > >
> > >> > > > > www.MediaTelGroup.co.uk
> > >> > > > >
> > >> > > > > MediaTel Group - Maximising efficiency across the entire
> > >> > > media process.
> > >> > > > >
> > >> > > > > Are you the best sporting brain in the industry? Visit
> > >> > > > > www.MediaTelGroup.co.uk/sportsquiz to enter our
> > >> > > Sports Quiz in aid
> > >> > > >of
> > >> > > > > Whizz-Kidz
> > >> > > > >
> > >> > > > >
> > >> > > > > This message is for the named recipient's use only and
> > >> > may contain
> > >> > > > > confidential or privileged information. If you receive
> > >> > > this message in
> > >> > > > > error, please immediately delete it and all copies of it
> > >> > > from your system,
> > >> > > > > destroy any hard copies of it and notify the sender.
> > >> > You must not,
> > >> > > >directly
> > >> > > > > or indirectly, use, disclose, distribute, print, or copy
> > >> > > any part of this
> > >> > > > > message if you are not the intended recipient. Email
> > >> > > communications are
> > >> > > >not
> > >> > > > > secure and therefore the MediaTel Group does not accept
> > >> > > liability for any
> > >> > > > > errors or omissions in the contents of this message which
> > >> > > arise as a
> > >> > > >result
> > >> > > > > of email transmission. MediaTel reserves the right to
> > >> > > monitor all email
> > >> > > > > communications through its networks. Any views expressed
> > >> > > by an individual
> > >> > > > > in this email do not necessarily reflect the views of the
> > >> > > MediaTel Group.
> > >> > > > >
> > >> > > > >
> > >> > > > > --
> > >> > > > > ** Archive:
> > >> > > http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
> > >> > > > >
> > >> > > > > To unsubscribe, e-mail:
> > [EMAIL PROTECTED]
> > >> > > > > For additional commands, e-mail:
> > >> > [EMAIL PROTECTED]
> > >> > > > > For human help, e-mail: [EMAIL PROTECTED]
> > >> > > > >
> > >> > > > >
> > >> > > >
> > >> > > >
> > >> > > >
> > >> > > >--
> > >> > > >** Archive:
> > >> > > http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
> > >> > > >
> > >> > > >To unsubscribe, e-mail:
> > [EMAIL PROTECTED]
> > >> > > >For additional commands, e-mail:
> > >> > [EMAIL PROTECTED] For
> > >> > > >human help, e-mail: [EMAIL PROTECTED]
> > >> > >
> > >> > >
> > >> > > --
> > >> > > ** Archive:
> > >> > http://www.mail-archive.com/dev%> 40lists.cfdeveloper.co.uk/
> > >> > >
> > >> >
> > >> > > To unsubscribe, e-mail:
> > >> > [EMAIL PROTECTED]
> > >> > > For additional commands, e-mail:
> > >> > [EMAIL PROTECTED] For
> > >> > > human help, e-mail: [EMAIL PROTECTED]
> > >> > >
> > >> >
> > >> >
> > >> > --
> > >> > ** Archive:
> > http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
> > >> >
> > >> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > >> > For additional commands, e-mail:
> > [EMAIL PROTECTED]
> > >> > For human help, e-mail: [EMAIL PROTECTED]
> > >> >
> > >> >
> > >>
> > >>
> > >>
> > >> --
> > >> ** Archive:
> > http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
> > >>
> > >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> > >> For additional commands, e-mail:
> > [EMAIL PROTECTED] For
> > >> human help, e-mail: [EMAIL PROTECTED]
> >
> >
> >
> > --
> > ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
> >
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail:
> > [EMAIL PROTECTED] For human help, e-mail:
> > [EMAIL PROTECTED]
> >
> >
>
>
>
> --
> ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
>
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> For human help, e-mail: [EMAIL PROTECTED]
>
>



-- 
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]


--
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]

Reply via email to