Forum > General

Fsearch,if Else problems

<< < (4/4)

Bart:

--- Quote from: RudieD on February 25, 2010, 01:45:20 am ---I know I shouldn't, .....

<snip>

 :-X I just couldn't help my self....
 >:D Don't do what I do, do what they say !  :D

--- End quote ---

One could also create a haslist for all commands allowed, then do a binary search in the hashlist?

Or use nested case statements.
Say we have 3 commands: Help, Halt, Install:


--- Code: ---case Command[1] of
  'H': case Command[2] of
         'E': case Command[3] of  etc. etc.
         'A':
         else //code for wrong input here
        end; 
  'I':  case Command[2] of
         'N': case Command[3] of etc.etc.
         else //code for wrong input here
       end;
  else //code for wrong input here
end;

--- End code ---

(I actually once wrote such piece of code with nested case statements to decode codons (3 successive letters (array[1..3] of char), coding for an amino-acid), where this approach proved to be faster then any other alternative anyone else came up with.)

Bart

eny:

--- Quote from: Bart on February 25, 2010, 04:28:41 pm ---One could also create a haslist for all commands allowed, then do a binary search in the hashlist?
--- End quote ---

Abstract a little futher and you end up with a design pattern  ::)

cdbc:
@RudieD

Nice piece of code mate, good on you :-)

Regards Benny

Navigation

[0] Message Index

[*] Previous page

Go to full version