DaLiMan Posted April 27, 2004 Posted April 27, 2004 Hi there, Is there a solution for the following script? start1: InputBox, string, name, tekst IfEqual, string, 0, goto, 0 IfEqual, string, 1, goto, 1 IfEqual, string, 2, goto, 2 0: Do something Goto, somewhere 1: Do something goto, somewhere Somewhere: MsBox, 4, name, tekst IfMsgBox, YES, Goto, start1 IfMsgBox, NO, Goto, end end: exit I can't seem to find out how this works with loops. Can anybody help me on the way?
jpm Posted April 27, 2004 Posted April 27, 2004 Hi there, Is there a solution for the following script? start1: InputBox, string, name, tekst IfEqual, string, 0, goto, 0 IfEqual, string, 1, goto, 1 IfEqual, string, 2, goto, 2 0: Do something Goto, somewhere 1: Do something goto, somewhere Somewhere: MsBox, 4, name, tekst IfMsgBox, YES, Goto, start1 IfMsgBox, NO, Goto, end end: exit I can't seem to find out how this works with loops. Can anybody help me on the way?Select Case $string="0" Case $string="1" Case $string="2" EndSelect
Administrators Jon Posted April 27, 2004 Administrators Posted April 27, 2004 (edited) Yes, but the way you do it depends on how much code you want to execute for "Do something" - if it is a lot then it would be neater to call a function. Otherwise something like this: Do If $string = "0" Then ; Do something ; ... ElseIf $string = "1" Then ; Do something ; ... ElseIf $string = "2" Then ; Do something ; ... EndIf Until MsgBox(4, "name", "tekst") = 7 You could also use the Case statement as JP said inplace of the If statements. Sooo omnay ways to skin this cat Edited April 27, 2004 by Jon
DaLiMan Posted April 27, 2004 Author Posted April 27, 2004 Thanks, I'm trying the following. But he says there is an error because there is no matching UNTIL statement for the DO statement. Can someone tell me what's wrong? ; ; V.3.0 ; $String = InputBox("Question", "type your number", "", "", -1, -1, 0, 0) Do If $string = "0" Then ; Something ; ... ElseIf $string = "1" Then ; Something ; ... ElseIf $string = "2" Then ; Something ; ... EndIf Func Something() MsgBox(4096, "Test", "This box will time out in 10 seconds", 10) EndFunc Until MsgBox(4, "name", "tekst") = 7
scriptkitty Posted April 27, 2004 Posted April 27, 2004 (edited) don't put a func inside a do..until, if....then, select....endselect, etc. Place them after everything else, or at the begining. I prefer the very end. ; ; V.3.0 ; $String = InputBox("Question", "type your number", "", "", -1, -1, 0, 0) Do If $string = "0" Then ; Something ; ... ElseIf $string = "1" Then ; Something ; ... ElseIf $string = "2" Then ; Something ; ... EndIf Until 1=1; need some condition as well MsgBox(4, "name", "tekst") = 7 ; keep all functions seperate, after all the rest. Func Something() MsgBox(4096, "Test", "This box will time out in 10 seconds", 10) EndFunc edit.. missed that Larry, I was looking at the forest instead of the trees. Edited April 27, 2004 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers.
DaLiMan Posted April 28, 2004 Author Posted April 28, 2004 OK, I can understand that. But when I choose 1 or 2 or .... the Function is not called upon. It go's straight to MsBox (4) before showing MsBox(4096) Also when I type something else like "A" it also goes to MsBox (4) in stead of giving an error. ; ; V.3.0 ; Do $String = InputBox("Question", "type your number", "", "", -1, -1, 0, 0) If $string = "0" Then ; Something ; ... ElseIf $string = "1" Then ; Something ; ... ElseIf $string = "2" Then ; Something ; ... EndIf Until MsgBox(4, "name", "tekst") = 7 ; keep all functions seperate, after all the rest. Func Something() MsgBox(4096, "Test", "This box will time out in 10 seconds", 10) EndFunc
jpm Posted April 28, 2004 Posted April 28, 2004 OK, I can understand that. But when I choose 1 or 2 or .... the Function is not called upon. It go's straight to MsBox (4) before showing MsBox(4096) Also when I type something else like "A" it also goes to MsBox (4) in stead of giving an error.I hope your misunderstanding does not come from the commented "; something" If you use the following version it works. The msgbox 4096 will execute only if the function is called ; ; V.3.0 ; Do $String = InputBox("Question", "type your number", "", "", -1, -1, 0, 0) If $string = "0" Then Something() ; ... ElseIf $string = "1" Then Something() ; ... ElseIf $string = "2" Then Something() ; ... EndIf Until MsgBox(4, "name", "tekst") = 7 ; keep all functions seperate, after all the rest. Func Something() MsgBox(4096, "Test " & $string, "This box will time out in 10 seconds", 10) EndFunc
DaLiMan Posted April 28, 2004 Author Posted April 28, 2004 That was really stupid of me.... ;Something in stead of Something().......Do you also know a solution for if someone enters another number than specified in the If..ElseIf..function?I need to give an error and start over again without going to the UNTIL MsBox.
Developers Jos Posted April 28, 2004 Developers Posted April 28, 2004 (edited) If $string = "0" Then Something() ; ... ElseIf $string = "1" Then Something() ; ... ElseIf $string = "2" Then Something() ; ... Else ; ... none of the above apply continueloop EndIf Edited April 28, 2004 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
DaLiMan Posted April 28, 2004 Author Posted April 28, 2004 Yes, Just thought of that ....Thanks anyway..... Have to work now for a while (It's piling up !!!) Thanks y'all.
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