Sign in to follow this  
Followers 0
anystupidassname

not equal range

9 posts in this topic

This doesn't work...

If $var <> "1" OR "2" OR "3' Then
 Exit
EndIf

Why not and is there a cleaner way to do it anyway? Say something like this for example:

If $var <> ["1"-"3"] Then
 Exit
EndIf

This signature is computer generated, nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#.......

Share this post


Link to post
Share on other sites



I think like this

If $var <> "1" OR $var <> "2" OR $var <> "3' Then

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

If $var <= 3 Then
 Exit
EndIf

would that do?


The speed of sound is defined by the distance from door to computer divided by the time interval needed to close the media player and pull up your pants when your mom shouts "OH MY GOD WHAT ARE YOU DOING!!!"

Share this post


Link to post
Share on other sites

If $var <= 3 Then
 Exit
EndIf

would that do?

Heh, nice try, but the var could be anything and I want it to abort unless it is specifically 1, 2, or 3

This signature is computer generated, nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#.......

Share this post


Link to post
Share on other sites

Shibuya, your code would exit if $var contained 2.5, 0 or -2. However such circumstances may not arise (it depends on the code used to assign the value in the first place) and in that case, yours would be the simplest and best way to do this.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

An alternative, but I don't consider it cleaner:

If StringInStr("1|2|3|", $var & "|") Then ...

Wait, shouldn't those OR's be AND's?

$var <> "1" AND $var <> "2" AND $var <> "3

equivalently:

Not ($var = 1 Or $var = 2 Or $var = 3)

Edited by CyberSlug

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

An alternative, but I don't consider it cleaner:

If StringInStr("1|2|3|", $var & "|") Then ...

Wait, shouldn't those OR's be AND's?

$var <> "1" AND $var <> "2" AND $var <> "3

equivalently:

Not ($var = 1 Or $var = 2 Or $var = 3)

Helpful as always. Thanks Slug! Thanks to the rest of you too.

Using OR instead of AND was my main problem.

Both:

If NOT $var <> "0" AND $var <> "1" AND $var <> "2" Then
    MsgBox(48, "Abort", "Something fubar!")
    Exit
EndIf

and:

If NOT StringInStr("0|1|2|", $var & "|") Then
    MsgBox(48, "Abort", "Something fubar!")
    Exit
EndIf

worked.


This signature is computer generated, nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#.......

Share this post


Link to post
Share on other sites

arent these the same

For $var = -1 to 4
$var1 = $var

If NOT $var <> "0" AND $var <> "1" AND $var <> "2" Then
    MsgBox(48, "Abort 1" , "Something fubar! " & $var, 3)
EndIf

If $var1 < "0" Or $var1 > "2" Then
    MsgBox(48, "Abort 2" , "Something fubar! " & $var1, 3)
EndIf

Next

The first one looks like the long road to get there

????

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

They will both give the same result if you can guarantee that $var holds an integer before you call them.

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
Sign in to follow this  
Followers 0