Switch versus if/then/else ( was: Main menu puzzle, Klaus)

Eric Chatonet eric.chatonet at sosmartsoftware.com
Sat Feb 18 17:37:31 EST 2006


Hi everyone,

Does switch is able to bring more flexibility and readability than if/ 
then/else?
The answer is yes.

You can write:

switch
   case x < 100
   case  x > 500
   case  x > 200 and x < 400
     <statements>
     break
   default
     <other statements>
end switch

With a conditional structure you would write:

if x < 100 or x > 500 or (x > 200 and x < 400) then
   <statements>
else
  <other statements>
end if

The first formulation seems much more clear to me :-)

Best Regards from Paris,
Eric Chatonet
------------------------------------------------------------------------ 
----------------------
http://www.sosmartsoftware.com/    eric.chatonet at sosmartsoftware.com/





More information about the use-livecode mailing list