Sign in to follow this  
Followers 0
Skitty

Input box calls wrong case

4 posts in this topic

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


Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites



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

Make yourself sheep and the wolves will eat you - Benjamin Franklin

Share this post


Link to post
Share on other sites

#4 ·  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

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0