Hellfire Posted February 5, 2006 Share 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. Link to comment Share on other sites More sharing options...
Xenobiologist Posted February 5, 2006 Share 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. 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 More sharing options...
Valuater Posted February 5, 2006 Share 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) Link to comment Share on other sites More sharing options...
Xenobiologist Posted February 5, 2006 Share 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 Link to comment Share on other sites More sharing options...
PsaltyDS Posted February 5, 2006 Share 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. 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 More sharing options...
Laine Posted February 5, 2006 Share Posted February 5, 2006 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 More sharing options...
PsaltyDS Posted February 5, 2006 Share Posted February 5, 2006 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 Link to comment Share on other sites More sharing options...
Richard Robertson Posted February 6, 2006 Share 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. Link to comment Share on other sites More sharing options...
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