| View previous topic :: View next topic |
| Author |
Message |
csharp Guest
|
Posted: Fri Jun 15, 2007 10:56 pm Post subject: How come this if statement is true? |
|
|
| 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
|
Posted: Fri Jun 15, 2007 10:58 pm Post subject: |
|
|
| 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 |
|
 |
csharp Guest
|
Posted: Sat Jun 16, 2007 12:10 am Post subject: |
|
|
| 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!  |
|
| Back to top |
|
 |
tic
Joined: 22 Apr 2007 Posts: 1356
|
Posted: Sat Jun 16, 2007 4:04 am Post subject: |
|
|
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 |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6772 Location: Pacific Northwest, US
|
Posted: Sat Jun 16, 2007 7:00 pm Post subject: |
|
|
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 |
|
 |
tic
Joined: 22 Apr 2007 Posts: 1356
|
Posted: Sun Jun 17, 2007 6:47 pm Post subject: |
|
|
| Ah! Lovely. Cheers |
|
| Back to top |
|
 |
|