Jump to content

Recommended Posts

Posted

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.

  • Developers
Posted

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.
  :)

Posted

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
Posted (edited)

lol wow!!! am i that slow?? i thought i was the first one to reply :D

Edit: My way wasn't that great either :huh2:

Edited by brett
-Brett
Posted (edited)

No, but I want 2 things to be true about an input statement.

Edit: Nevermind, I figured it out, but thanks anyway.

Edited by SweatyOgre
  • 2 weeks later...
Posted (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 by Nutster

David Nuttall
Nuttall 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...

Posted

[off-topic]

JdeB ever played Diablo II ? thought about it when i saw "Norm", "Night" and "Hell" :D

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...