Alaska Software Inc. - Strange string comparison failure
Username: Password:
AuthorTopic: Strange string comparison failure
Fabio CavalloneStrange string comparison failure
on Fri, 18 Apr 2014 12:33:44 +0200
Hi to all.
Can anyone explain me this (1.90.355) ?

"hi" == ""   => .F.  OK!
"hi" != ""   =>  .F.   ??
"hi" <> ""  =>  .F.   ??

and then:

"" == "hi"  ==> .F.  OK!
"" != "hi"  ==> .T.  OK !
"" <> "hi" ==> .T.  OK !

Thanks
Fabio
Andreas Gehrs-Pahl
Re: Strange string comparison failure
on Fri, 18 Apr 2014 10:49:34 -0400
Fabio,

>Can anyone explain me this (1.90.355) ?

This is expected behavior, and not a bug.

Basically, "==" is the "always exact" equal comparison operator, while "=" 
is the "inexact" equal comparison operator. The "inexact" not equal 
comparison operators: "#", "<>", and "!=" behave the same as ".not. =", or 
the opposite of the "inexact" equal comparison operator.

The "==" comparison is independent of the "Set Exact" setting, while all 
other also depend on that setting.

If an inexact comparison is made, the (string) value on the left side of 
the operator is tested only for the length of the (string) value on the 
right side of the operator, so all strings are equal to an empty string, 
while empty strings are only equal to other empty strings.

RTFM on "SET EXACT" for more details on this.

Hope that helps,

Andreas

Andreas Gehrs-Pahl
Absolute Software, LLC

phone: (989) 723-9927
email: Andreas.GP@Charter.net
web:   http://www.Aerospace-History.net