Sign in to follow this  
Followers 0
Hell4Ge

NOT operator, how it works?

5 posts in this topic

#1 ·  Posted (edited)

$a = 10 If not $a = 5 Then MsgBox(0, "TADAAAM!", "TADAAAAM!") EndIf

MsgBox did not show

So I think that maybe sth is wrong with my brain, but when I asked myself for:

- I am drunk?

- DId I take the drugs?

- Did some1 hit my head with lantern?

- Did some dragons / aliens fly over the red lights at crossroad yesterday?

Nope, I dont think so

The summary is: What the hell is wrong with this code? :o

NVM :P

My brain is okay, my reading skills are dead at now

BOOLEAN FCK YEAH!

Edited by Hell4Ge

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

It is due the order in which the comparison is interpreted.

AutoIt is seeing "If (Not $a) = 5 Then"

If Not ($a = 5) would return different results.

Edit: You could also accomplish the same with "If $a <> 5 Then"

Edited by Spiff59

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Typically you use the Not operator for testing/assigning boolean values.

Edited by Kidney

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

_SomeFunction()
If Not @error then
_DoSomething()
Else
_DoSomethingElse()
EndIf

The following code will yield the same results

_SomeFunction()
If @error then
_DoSomethingElse()
Else
_DoSomething()
EndIf

See? The "Not" just reverses the logic.

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

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