SweatyOgre Posted May 25, 2004 Share Posted May 25, 2004 I would like to force the user of my program to enter one of three words in an input box. What would be the best way to go about that? Here is the code for the inputbox: $Difficulty = InputBox ("Difficulty", "Enter the difficluty at which you wish to do the pindle runs:", "norm, night, or hell") The three words are "norm", "night", and "hell" I was thinking a loop that makes the user re-enter the information until they use one of the words, but I'm not sure which loop would be best. Link to comment Share on other sites More sharing options...
Developers Jos Posted May 25, 2004 Developers Share Posted May 25, 2004 something like this ? Do $Difficulty = InputBox ("Difficulty", "Enter the difficluty at which you wish to do the pindle runs:") Until $Difficulty = "norm" or $Difficulty = "night" or $Difficulty = "hell" 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. Link to comment Share on other sites More sharing options...
SweatyOgre Posted May 25, 2004 Author Share Posted May 25, 2004 Thank you, I was trying something with a While...WEnd or an If...Then statement, this is much simpler. Link to comment Share on other sites More sharing options...
Developers Jos Posted May 25, 2004 Developers Share Posted May 25, 2004 if your list gets longer you can also use this trick: Until StringInStr("|norm|night|hell|","|" & $Difficulty & "|") 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. Link to comment Share on other sites More sharing options...
brett Posted May 25, 2004 Share Posted May 25, 2004 theres lots of ways, one way may be like this Ask() Func Ask() Global $Difficulty = InputBox ("Difficulty", "Enter the difficluty at which you wish to do the pindle runs:", "norm, night, or hell") Check() Endfunc Func Check() Select Case $Difficulty = "norm" ContinueNorm() Case $Difficulty = "night" ContinueNight() Case $Difficulty = "hell" ContinueHell() Case Else Ask() EndSelect Endfunc Func ContinueNorm() EndFunc Func ContinueHell() Endfunc Func ContinueNight() Endfunc Does this help at all? -Brett Link to comment Share on other sites More sharing options...
brett Posted May 25, 2004 Share Posted May 25, 2004 (edited) lol wow!!! am i that slow?? i thought i was the first one to reply Edit: My way wasn't that great either Edited May 25, 2004 by brett -Brett Link to comment Share on other sites More sharing options...
SweatyOgre Posted May 25, 2004 Author Share Posted May 25, 2004 What if I wanted to do until 2 conditions were true? Link to comment Share on other sites More sharing options...
Developers Jos Posted May 25, 2004 Developers Share Posted May 25, 2004 (edited) you need to explain this..... Will you have 2 input statements then? Edited May 25, 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. Link to comment Share on other sites More sharing options...
SweatyOgre Posted May 25, 2004 Author Share Posted May 25, 2004 (edited) No, but I want 2 things to be true about an input statement. Edit: Nevermind, I figured it out, but thanks anyway. Edited May 25, 2004 by SweatyOgre Link to comment Share on other sites More sharing options...
SlimShady Posted May 25, 2004 Share Posted May 25, 2004 No, but I want 2 things to be true about an input statement.You can use AND instead of OR. Link to comment Share on other sites More sharing options...
Nutster Posted June 4, 2004 Share Posted June 4, 2004 (edited) theres lots of ways, one way may be like this <Code Removed> Does this help at all?The only problem with this is the level of recursion. Try: (watch word wrap) Dim $Difficulty, $Test Do $Difficulty = InputBox ("Difficulty", "Enter the difficulty at which you wish to do the pindle runs:", "norm, night, or hell") If @Error then Exit Endif $Difficulty = StringLower(StringStripWS($Difficulty, 3)) $Test=StringInStr("|norm|night|hell|","|" & $Difficulty & "|") If $Test=0 then MsgBox(0,"Invalid Info", "That is not a valid answer. Please try again." Endif Until $Test > 0 Select Case $Difficulty = "norm" ; Do normal Case $Difficulty = "night" ; Do night level Case $Difficulty = "hell" ; Do hell level EndSelect Edited June 4, 2004 by Nutster David NuttallNuttall Computer Consulting An Aquarius born during the Age of Aquarius AutoIt allows me to re-invent the wheel so much faster. I'm off to write a wizard, a wonderful wizard of odd... Link to comment Share on other sites More sharing options...
Dev Posted June 4, 2004 Share Posted June 4, 2004 [off-topic] JdeB ever played Diablo II ? thought about it when i saw "Norm", "Night" and "Hell" Link to comment Share on other sites More sharing options...
Developers Jos Posted June 4, 2004 Developers Share Posted June 4, 2004 Nope... just Cut&Paste from SweatyOgre.... see first post .... 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. 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