home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 1992 August / info-mac-1992.iso / Source / Pascal / Chat / Chat 1.0.0 Source / My Libraries / MyStripTelnetCodes.unit < prev    next >
Encoding:
Text File  |  1992-04-26  |  695 b   |  42 lines  |  [TEXT/PJMM]

  1. unit MyStripTelnetCodes;
  2.  
  3. { This program was written by Peter N Lewis, Mar 1992 in THINK Pascal 4.0.1 }
  4.  
  5. interface
  6.  
  7.     procedure StripTelnetCodes (var s: string);
  8.  
  9. implementation
  10.  
  11.     const
  12.         T_will = chr(251);
  13.         T_wont = chr(252);
  14.         T_Do = chr(253);
  15.         T_Dont = chr(254);
  16.         T_IAC = chr(255);
  17.  
  18.     procedure StripTelnetCodes (var s: string);
  19.         var
  20.             i: integer;
  21.     begin
  22.         i := 1;
  23.         while i < length(s) do begin
  24.             if s[i] <> T_IAC then
  25.                 i := i + 1
  26.             else begin
  27.                 case s[i + 1] of
  28.                     T_IAC:  begin
  29.                         Delete(s, i, 1);
  30.                         i := i + 1;
  31.                     end;
  32.                     T_will, T_wont, T_do, T_dont:  begin
  33.                         Delete(s, i, 3);
  34.                     end;
  35.                     otherwise
  36.                         Delete(s, i, 2);
  37.                 end;
  38.             end;
  39.         end;
  40.     end;
  41.  
  42. end.