Jump to content

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.

Link to comment
Share on other sites

  • Developers
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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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

 

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...