Subj : Translating CASE from BAS
To   : Mike Luther
From : mark lewis
Date : Sat Feb 10 2001 04:09 am

ML> Yes, Mark .

ml>> ... even if only to assign a single value to
ml>> be able to case or switch with... however, doing that
ml>> if/then/else tree once and then using the single value
ml>> every else is much better than using if/then/else
ml>> everywhere that you need to branch based on that
ml>> selection...

ML> Wincing .. "The devil you know is better than the devil you
ML> don't?"

hehehe... i know that feeling...

one of the things i was thinking about while writting the above was 'program
efficiency'... in some situations this can be important...

if switch case is faster then if/then/else, then 'converting' to single value
for that purpose once is a necessary evil until such time as one gets the
chance to rework that section...

thinking about situations where the switch case stuff may possibly be executed
hundreds of times a second vs if/then/else trees running hundreds of times a
second...

== example ==
 red    == 1;
 blue   == 2;
 yellow == 3;

procedure routine1;
{
 input "what's your color?",color$;
 if color$ = "red" then color == red
   else if
     color$ = "blue" then color == blue
       else if
         color$ = "yellow" then color == yellow;
}

procedure routine2;
{
 case color of
  red : do_red_routine;
  blue : do_blue_routine;
  yellow : do_yellow_routine;
}

procedure routine3;
{
 case color of
  red : do_red_routine2;
  blue : do_blue_routine2;
  yellow : do_yellow_routine2;
}

{
 routine1;
 while 1==1 do
 {
   routine2;
   routine3;
 }
}
== end of example ==

)\/(ark


* Origin: (1:3634/12)