IvanCodin Posted September 28, 2009 Share Posted September 28, 2009 (edited) Can you use an if statement this way: If $var1 = "1" or '2" or "3" Then msgbox(0,"info", "You used one, two or three") EndIf Or is a case statement like this required for more than three variables? Case $var1 = "1" msgbox(0,"info", "You used one, two or three") Case $var1 = "2" msgbox(0,"info", "You used one, two or three") Case $var= "3" msgbox(0,"info", "You used one, two or three") EndSelect Me Edited September 28, 2009 by IvanCodin Link to comment Share on other sites More sharing options...
complex Posted September 28, 2009 Share Posted September 28, 2009 I had better luck with the case... http://www.autoitscript.com/forum/index.php?app=forums&module=post§ion=post&do=reply_post&f=2&t=103096&qpid=730789 Select Case $var1 = "1" msgbox(0,"info", "You used one") Case $var1 = "2" msgbox(0,"info", "You used two") Case $var1 = "3" msgbox(0,"info", "You used three") EndSelect But you should be able to do both If $var1 = "1" msgbox(0,"info", "You used one") ElseIf $var1 = "2" Then msgbox(0,"info", "You used two") Else $var1 = "3" msgbox(0,"info", "You used three") EndIf Link to comment Share on other sites More sharing options...
smashly Posted September 28, 2009 Share Posted September 28, 2009 Hi,expandcollapse popup$var1 = 2 If $var1 = 1 or $var1 = 2 or $var1 = 3 Then msgbox(0,"info", $var1) ;Or Switch $var1 Case 1,2,3 msgbox(0,"info", $var1) EndSwitch ;Or Switch $var1 Case 1 To 3 msgbox(0,"info", $var1) EndSwitch ;Or Switch $var1 Case 1 msgbox(0,"info", $var1) Case 2 msgbox(0,"info", $var1) Case 3 msgbox(0,"info", $var1) EndSwitch ;Or Select Case $var1 = 1 Or $var1 = 2 Or $var1 = 3 msgbox(0,"info", $var1) EndSelect ;Or Select Case $var1 > 0 And $var1 < 4 msgbox(0,"info", $var1) EndSelect ;Or Select Case $var1 = 1 msgbox(0,"info", $var1) Case $var1 = 2 msgbox(0,"info", $var1) Case $var1 = 3 msgbox(0,"info", $var1) EndSelect ; All do the same thing ; there's quite a lot of ways more to do the same thing ; Just depends on your needs and preference. Cheers Link to comment Share on other sites More sharing options...
IvanCodin Posted September 28, 2009 Author Share Posted September 28, 2009 Thanks!! It didn't error when I used syntaxcheck but I didn't find anything in thr help file for the if $var1 = '1" or "2" bla bla Me Link to comment Share on other sites More sharing options...
Coolw Posted September 28, 2009 Share Posted September 28, 2009 Try If $var1 = "1" or $var1 = "2" or $var = "3" Then Blah My ProgramsMy WIP'sSteam Server Restarter 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