Sign in to follow this  
Followers 0
PsaltyDS

How come 'NOT' does not work on string compares?

3 posts in this topic

I had a logic explosion in one of my scripts, and just figured out that 'NOT' does not work in string compares. Is that by design?

:lmao:

Demo of my problem:

; Test string compares

$Text1 = "One"
$Text2 = "Two"

If $Text1 = $Text2 Then
    MsgBox(32, "Compare with =", '"' & $Text1 & '" is equal to "' & $Text2 & '"')
Else
    MsgBox(32, "Compare with =", '"' & $Text1 & '" is not equal to "' & $Text2 & '"')
EndIf

If Not $Text1 = $Text2 Then
    MsgBox(32, "Compare with Not =", '"' & $Text1 & '" is not equal to "' & $Text2 & '"')
Else
    MsgBox(32, "Compare with Not =", '"' & $Text1 & '" is equal to "' & $Text2 & '"')
EndIf

If $Text1 == $Text2 Then
    MsgBox(32, "Compare with ==", '"' & $Text1 & '" is equal to "' & $Text2 & '"')
Else
    MsgBox(32, "Compare with ==", '"' & $Text1 & '" is not equal to "' & $Text2 & '"')
EndIf

If Not $Text1 == $Text2 Then
    MsgBox(32, "Compare with Not ==", '"' & $Text1 & '" is not equal to "' & $Text2 & '"')
Else
    MsgBox(32, "Compare with Not ==", '"' & $Text1 & '" is equal to "' & $Text2 & '"')
EndIf

If $Text1 <> $Text2 Then
    MsgBox(32, "Compare with <>", '"' & $Text1 & '" is not equal to "' & $Text2 & '"')
Else
    MsgBox(32, "Compare with <>", '"' & $Text1 & '" is equal to "' & $Text2 & '"')
EndIf

If Not $Text1 <> $Text2 Then
    MsgBox(32, "Compare with Not <>", '"' & $Text1 & '" is equal to "' & $Text2 & '"')
Else
    MsgBox(32, "Compare with Not <>", '"' & $Text1 & '" is not equal to "' & $Text2 & '"')
EndIf

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites



hello

i have had the same problem : take a look here

If Not $Text1 = $Text2

(not $text1) is first evaluated, and = is evaluated after.

Try

if not($text1 = $text2)

Share this post


Link to post
Share on other sites

hello

i have had the same problem : take a look here

If Not $Text1 = $Text2

(not $text1) is first evaluated, and = is evaluated after.

Try

if not($text1 = $text2)

Ahh, I see, said the blind man...

Works the same way with numeric compares, I hadn't noticed that. Thanks! ;)

I used ta couldn't spell poorgrammer, now I are one! Thanks to the AutoIT3 Forums! :lmao:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0