Switch statement
Nonsanity
nonsanity at fluffandsuch.com
Wed Aug 4 10:56:41 EDT 2004
If you are searching for your words in a larger string, then this won't
work with a case statement. Case statements are better (that is,
slightly faster - maybe) than if-then-else chains when you are comparing
a single variable with multiple constants. If you need to perform
processing (like a "contains" find-like command) or use multiple
variables and conditions, or compare against other variables... Then
case is not the way to go. If your "Text" variable contains nothing but
"ballast", "bulk", or something else, then just drop the "contains"
keyword. If "Text" is a larger string, like "16-ton ballast" (which in
your case it is), then switch to a chained if-then-else:
if "ballast" is in Text then
put "no cargo" into fld "e4"
else if "bulk" is in Text then
put "oil bunkjers into fld "e5"
else
put "general cargo" into fld "e6"
end if
~ Chris Innanen
~ Nonsanity
~ AIM: FluffAndSuch
Bill wrote:
> 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.
>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
More information about the use-livecode
mailing list