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"
            break
        case (mainChoice is empty or mainChoice is "This menu script")
            put the long id of me into scriptObject
            break
        case (word 1 of mainChoice is "Library")
            put the name of stack secondChoice into scriptObject
            break
        case "Unsorted"
            edit the script of stack "libOPN_Unsorted"
            break
        default
            breakpoint
    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