likeanooobox

If statement ignores my And section

3 posts in this topic

#1 ·  Posted

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 this post


Link to post
Share on other sites



#2 ·  Posted

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


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted

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

 

 

Share this post


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