AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How come this if statement is true?

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
csharp
Guest





PostPosted: Fri Jun 15, 2007 10:56 pm    Post subject: How come this if statement is true? Reply with quote

Code:


a = 1
b = 2
c = 3

if ((a = 1 and b = 3) or c = 3)
{
   msgbox, true
}



The paranthesis do nothing?

How should I think when making if-statements with several "or/and" without using paranthesis? Should I avoid it?

Best Regards
Back to top
mwharri



Joined: 15 Mar 2007
Posts: 70

PostPosted: Fri Jun 15, 2007 10:58 pm    Post subject: Reply with quote

it's true b/c variable 'c' does equal 3.....if (a and b) OR c....c is true, therefore, statement is true. If c is true, then a and b are irrelevant...if c is a and b are true, then c is irrelevant.
Back to top
View user's profile Send private message
csharp
Guest





PostPosted: Sat Jun 16, 2007 12:10 am    Post subject: Reply with quote

mwharri wrote:
it's true b/c variable 'c' does equal 3.....if (a and b) OR c....c is true, therefore, statement is true. If c is true, then a and b are irrelevant...if c is a and b are true, then c is irrelevant.


Oops. Thanks mwharri! Mistakes like that can be very hard to detect yourself sometimes. Now I understand. The paranthesis does work! Smile
Back to top
tic



Joined: 22 Apr 2007
Posts: 1356

PostPosted: Sat Jun 16, 2007 4:04 am    Post subject: Reply with quote

Although I'm a little confuded at some of the and/ or parts, such as:

Code:
IfWinExist, Calculator and WinNotExist, Notepad
{
...
}


I know thats junk, but what should it be when writing and/or with winexist/notexist?
Back to top
View user's profile Send private message
engunneer



Joined: 30 Aug 2005
Posts: 6772
Location: Pacific Northwest, US

PostPosted: Sat Jun 16, 2007 7:00 pm    Post subject: Reply with quote

use the function form of WinExist()

Code:

If WinExist("Notepad")=0 and WinExist("Calculator")!=0
{


}

_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM
Back to top
View user's profile Send private message Visit poster's website
tic



Joined: 22 Apr 2007
Posts: 1356

PostPosted: Sun Jun 17, 2007 6:47 pm    Post subject: Reply with quote

Ah! Lovely. Cheers
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group