Switch statement

Rob Cozens rcozens at pon.net
Wed Aug 4 09:50:35 CDT 2004


>  switch (Text) contains
>     case "ballast"
>       put "no cargo" into fld "e4"
>       break
>     case "bulk"
>       put "oil bunkers" into fld "e5"
>       break
>     default
>       put "general cargo" into fld "e6"
>   end switch
>
>The above is a simple switch where (Text) is more than one word and I am
>looking to see if that list of words contains one particular word. I have
>tried every possible permutation of this and can't find the simple answer.
>Maybe I have to do like in MySQL and put ? Before and after my search word
>although that is particular for MySQL.
>
>What is the easiest way to do this (other than three separate if statements)
>-- I would like to get the switch working with a "contains" search.


>remove "contains"

Sorry, Bill.

I understood Text to contain only the text in the case definitions.

If there is other text in Text as well, how about:

  switch
     case  (Text) contains"ballast"
       put "no cargo" into fld "e4"
       break
     case  (Text) contains"bulk"
       put "oil bunkers" into fld "e5"
       break
     default
       put "general cargo" into fld "e6"
   end switch

-- 

Rob Cozens
CCW, Serendipity Software Company

"And I, which was two fooles, do so grow three;
Who are a little wise, the best fooles bee."

from "The Triple Foole" by John Donne (1572-1631)


More information about the use-livecode mailing list