Jump to content

If $var=1 or $var=2 then


 Share

Recommended Posts

How can I create a or in an if then else function.

If $var=1 or $var=2 then

...

else

...

endif

It always goes to the then even when it doesnt equal 1 or 2.

The should be easy.

;$var = 1
$var = 3

If $var=1 or $var=2 then
MsgBox(0, "Hit", "$var = 1 or 2")
else
MsgBox(0, "Hit", "$var <> 1 or 2")
endif

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Hihi, I was faster :lmao:

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

How can I create a or in an if then else function.

If $var=1 or $var=2 then

...

else

...

endif

It always goes to the then even when it doesnt equal 1 or 2.

That should work. Maybe you could flesh out your example with some more code?

For $var = 0 To 3
     If $var=1 Or $var=2 Then
          MsgBox(64, "Match", "Match!  $var = " & $var)
     Else
          MsgBox(64, "No Match", "Did not match!  $var = " & $var)
     EndIf
Next
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

That should work. Maybe you could flesh out your example with some more code?

For $var = 0 To 3
     If $var=1 Or $var=2 Then
          MsgBox(64, "Match", "Match!  $var = " & $var)
     Else
          MsgBox(64, "No Match", "Did not match!  $var = " & $var)
     EndIf
Next
For a twist:

For $var = 0 To 3
     If $var<1 Or $var>2 Then
           MsgBox(64, "No Match", "Did not match!  $var = " & $var)
     Else
         MsgBox(64, "Match", "Match!  $var = " & $var)
     EndIf
Next
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...