Jump to content

Recommended Posts

Posted

Func _Select()
$I = InputBox("Command Center"," ","","",200,100)
Select
    Case $I = "kill" Or "exit" Or "stop" Or "Kill" Or "Exit" Or "Stop" Or "KILL" Or "EXIT" Or "STOP"
        Exit
    Case $I = "create" Or "Create" Or "CREATE"
        _create()
    Case $I = "lock" Or "Lock" Or "LOCK"
        _lock()
    Case $I = "unlock" Or "Unlock" Or "UNLOCK" Or "un-lock" Or "Un-lock" Or "UN-LOCK" or "un lock" Or "Un lock" Or "UN LOCK" Or "Un Lock" Or "Un-Lock"
        _unlock()
    Case $I = "google" Or "Google" Or "GOOGLE"
        ShellExecute("http://www.google.com")
    Case $I = "au3"
        ShellExecute("http://www.autoitscript.org")
    Case Else
        MsgBox(0,"Syntax error","'" & $I & "'" & " is not recognized as an internal or external command." & _
        @LF  & "Correct your syntax and try again.")
EndSelect
EndFunc

I find that with an excessive amount of Or's my program just skips the whole case thing. but if I remove a few of them then its all cool. whyPosted Image

Posted

Cases are "case insensitive" - try it with Switch - looks nicer without Or's

Func _Select()
    Local $I = InputBox("Command Center", " ", "", "", 200, 100)
    Switch $I
        Case "kill", "exit", "stop"
            Exit
        Case "create"
            _create()
        Case "lock"
            _lock()
        Case "unlock", "un-lock", "un lock"
            _unlock()
        Case "google"
            ShellExecute("http://www.google.com")
        Case "au3"
            ShellExecute("http://www.autoitscript.org")
        Case Else
            MsgBox(0, "Syntax error", "'" & $I & "'" & " is not recognized as an internal or external command." & _
                    @LF & "Correct your syntax and try again.")
    EndSwitch
EndFunc

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Posted (edited)

That is not how you do Or.

This is how you Or:

$I = "kill" Or $I = "exit"

See "Language Reference - Conditional Statements" in helpfile.

Thank you, now I know for future reference!

Cases are "case insensitive" - try it with Switch - looks nicer without Or's

Thanks. What ripdad stated fixed my issue!

Edited by xJSLRx

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