Switch Statement

Eric Chatonet eric.chatonet at sosmartsoftware.com
Thu Jul 12 08:11:56 EDT 2007


Hi David,

If you specify a variable just after the switch statement, each case  
value refers to this variable.
So, in your case, try:

     switch -- note there is nothing more here ;-)
         case mainChoice = "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 mainChoice = "Unsorted"
             edit the script of stack "libOPN_Unsorted"
             break
         default
             breakpoint
     end switch

Hope this helps :-)

Le 12 juil. 07 à 14:06, David a écrit :

> 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?

Best regards from Paris,
Eric Chatonet.
----------------------------------------------------------------
Plugins and tutorials for Revolution: http://www.sosmartsoftware.com/
Email: eric.chatonet at sosmartsoftware.com/
----------------------------------------------------------------





More information about the Use-livecode mailing list