home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast.iso / pcmag / vol6n20.zip / FIGURES.ZIP / FIGURE.5 < prev    next >
Text File  |  1987-10-16  |  1KB  |  38 lines

  1.   (* This case statement lists all the case labels
  2.      in numeric order.  There is no overlap -- a
  3.      given character matches one and only one case.
  4.      If MyChar is an ordinary alphanumeric character,
  5.      the program will make 10 comparisons before
  6.      matching it.   SLOWER!*)
  7.   CASE Ord(MyChar) OF
  8.        0..7 : Do_Control_Char;
  9.           8 : Do_Backspace;
  10.           9 : Do_Tab;
  11.          10 : Do_LF;
  12.       11,12 : Do_Control_Char;
  13.          13 : Do_CR;
  14.      14..26 : Do_Control_Char;
  15.          27 : Do_Escape;
  16.      28..31 : Do_Control_Char;
  17.     32..127 : Do_Lower_ASCII;
  18.     ELSE Do_Upper_ASCII;
  19.   END;
  20.  
  21.   (* This case statement lists its labels in
  22.      order from most often used to least.  If
  23.      MyChar is alphanumeric, only one comparison
  24.      will be required.  Also, by letting the
  25.      special control characters overlap the general
  26.      case for control characters, it reduces the
  27.      total number of labels required.  FASTER!*)
  28.   CASE Ord(MyChar) OF
  29.     32..127 : Do_Lower_ASCII;  {Most frequent first}
  30.          10 : Do_LF;
  31.          13 : Do_CR;
  32.           8 : Do_Backspace;
  33.           9 : Do_Tab;
  34.          27 : Do_Escape;
  35.       0..31 : Do_Control_Char; {Overlaps}
  36.     ELSE Do_Upper_ASCII;
  37.   END;
  38.