Switch Statement

David david.bovill at gmail.com
Thu Jul 12 08:06:58 EDT 2007

I use the switch statement a lot - but only for basic "case" tests and
have not been able to get:

   "If the caseValue is equal to the switchExpression, or the
caseCondition evaluates to true"

working. Here is an example that I just changed from "if then else" -
whats wrong with it:

    switch mainChoice
        case "Go to script object"
        case (mainChoice is empty or mainChoice is "This menu script")
            put the long id of me into scriptObject
        case (word 1 of mainChoice is "Library")
            put the name of stack secondChoice into scriptObject
        case "Unsorted"
            edit the script of stack "libOPN_Unsorted"
    end switch

My understanding is that:

  (word 1 of mainChoice is "Library")

is an expression which evaluated to true or false - but steeping
through i the debugger when mainChoice is "Library" the case statement
is not triggered and instead the default case statement is activated?

More information about the Use-livecode mailing list