Jump to content
Sign in to follow this  
Hell4Ge

NOT operator, how it works?

Recommended Posts

Hell4Ge

$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
Spiff59

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
Kidney

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

Edited by Kidney

Share this post


Link to post
Share on other sites
Blue_Drache

_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  

×