Main menu puzzle, Klaus

J. Landman Gay jacque at
Sat Feb 18 17:56:32 EST 2006

Garrett Hylltun wrote:

> And to this day, I just don't understand the whole purpose of the  Case 
> statement.....  Still don't even after reading a few of the  replies to 
> this thread.

I prefer switch/case statements when there are many options a script has 
to deal with. I'll admit though that there is little difference between 
switch/case and if/then constructs when the choices are straightforward.

There is an advantage to using switch statements though when several 
options need to result in the same behavior. For example:

if tColor = "red" or tColor = "blue" or tColor = "purple" or tColor = 
"green" then
else if tColor = "black" or tColor = "white" then
end if

Sometimes these constructs can get very complicated, at least visually. 
A switch/case statement "falls through" to the next line unless it hits 
a "break", so the above can be represented instead like this:

case "red"
case "blue"
case "purple"
case "green"
case "black"
case "white"

The above construction is easier for me to read and executes faster in a 

Jacqueline Landman Gay         |     jacque at
HyperActive Software           |

More information about the Use-livecode mailing list