# AND OR operator question

## Recommended Posts

I don't know exactly how autoit cumulates and handles AND and OR operators.

If \$c = \$d AND \$a + \$b = 14 AND \$a = 1 OR \$b = 1 Then

I'm not sure how the OR will be treated.

For this to be TRUE, I want:

\$c = \$d must be TRUE

\$a + \$b = 14 must be TRUE

\$a = 1 OR \$b=1 one of these two must be TRUE (So \$a=1 is sufficient, \$b doesn't have to be 1, but if \$a <> 1, \$b has to be 1)

Will this work?

Or do I have to create another IF statement within the first IF statement? Or is there another possibility like working with ()'s like

If \$c = \$d AND \$a + \$b = 14 AND (\$a = 1 OR \$b = 1) Then

Thanks!

##### Share on other sites

Thanks!

Didn't know if parentheses would work in an If statement but apparently they do.

Thanks again!

##### Share on other sites

In order of operations, boolean operators usually come last. At that point they are evaluated from left to right. [usually]

##### Share on other sites

so

```\$a=1
\$b=1
\$c=1
\$d=1
If \$a = 1 AND \$a+\$b=2 AND (\$c = 1 OR \$d = 1) Then
MsgBox(0,"","Passed",0)
Else
MsgBox(0,"","Failed",0)
EndIf```

is a good test for me

## Create an account

Register a new account

×

• Wiki

• Back

• Git