Hellfire Posted February 5, 2006 Posted February 5, 2006 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.
Xenobiologist Posted February 5, 2006 Posted February 5, 2006 Hellfire said: 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
Valuater Posted February 5, 2006 Posted February 5, 2006 maybe this $var = 5 If $var = 1 Or $var = 2 Then MsgBox(0, "IS", " the var is 1 or 2 ") Else MsgBox(0, "NOT", " the var is not 1 or 2 ") EndIf 8)
Xenobiologist Posted February 5, 2006 Posted February 5, 2006 Hihi, I was faster 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
PsaltyDS Posted February 5, 2006 Posted February 5, 2006 Hellfire said: 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
Laine Posted February 5, 2006 Posted February 5, 2006 PsaltyDS said: 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
PsaltyDS Posted February 5, 2006 Posted February 5, 2006 th.meger said: Hihi, I was faster But my code was better... THBBBBBBbbbbbbt! 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
Richard Robertson Posted February 6, 2006 Posted February 6, 2006 I'm so confused... Why wouldn't "If $var = 1 or $var = 2 Then..." work right? I've used a ton of statements like that with no problems.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now