Jump to content
Sign in to follow this  
kor

Can someone help me understand Switch statements?

Recommended Posts

kor

$hailfrom = "bulkcreatestaff"

Switch $hailfrom
    Case "create" Or "delete" Or "move" Or "some" Or "other" Or "thing"
        consolewrite("1,create,delete,move,some,other,thing" & @CR)
    Case "bulkcreatestaff" Or "bulkdelete" Or "bulkmove" Or "bulksome"
        consolewrite("2,bulk,create,bulk,move,bulk,some" & @CR)
EndSwitch

Why is it, that if my var $hailfrom = "bulkcreatestaff" I am still seeing the first consolewrite instead of the second.

What kind of pattern matching is being done here? Does the case check for any instance of "create" in the var? I always though it checked the entire value for an exact match.

Share this post


Link to post
Share on other sites
Jos

Or is not the proper syntax:

$hailfrom = "bulkcreatestaff"

Switch $hailfrom
    Case "create", "delete", "move", "some", "other", "thing"
        consolewrite("1,create,delete,move,some,other,thing" & @CR)
    Case "bulkcreatestaff", "bulkdelete", "bulkmove", "bulksome"
        consolewrite("2,bulk,create,bulk,move,bulk,some" & @CR)
EndSwitch

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
kor

I appreciate it. Thanks.

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  

×