Jump to content

Can someone help me understand Switch statements?


 Share

Recommended Posts

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

Link to comment
Share on other sites

  • Developers

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

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

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
 Share

  • Recently Browsing   0 members

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