# If statement ignores my And section

## Recommended Posts

```Global \$vars[6] = [0,1,2,3,"",""]

Global \$currentvar = 4

Global \$counter=0
\$counter+=1
\$counter+=1

If Mod(\$counter,2)=0 And \$currentvar=\$vars[0] or \$vars[1] or \$vars[2] or \$vars[3] Then
ConsoleWrite(\$counter)
EndIf```

For some reason I'm writing this If statement and it won't compare my \$currentcar to the \$vars array. In the console it outputs two, but clearly 4 is not equal to 0,1,2, or 3.

##### Share on other sites
`If Mod(\$counter,2)=0 And \$currentvar=\$vars[0] or \$vars[1] or \$vars[2] or \$vars[3] Then`

This doesn't work like you expect and guess you need something like this

`If Mod(\$counter,2)=0 And (\$currentvar=\$vars[0] or \$currentvar=\$vars[1] or \$currentvar=\$vars[2] or \$currentvar=\$vars[3]) Then`

Jos

Live for the present,
Dream of the future,
Learn from the past.

##### Share on other sites

Wow, yea I never knew that. Thanks!

20 minutes ago, Jos said:
`If Mod(\$counter,2)=0 And \$currentvar=\$vars[0] or \$vars[1] or \$vars[2] or \$vars[3] Then`

This doesn't work like you expect and guess you need something like this

`If Mod(\$counter,2)=0 And (\$currentvar=\$vars[0] or \$currentvar=\$vars[1] or \$currentvar=\$vars[2] or \$currentvar=\$vars[3]) Then`

Jos

## Create an account

Register a new account