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/ 
The answer is yes.

You can write:

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

With a conditional structure you would write:

if x < 100 or x > 500 or (x > 200 and x < 400) then
  <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