home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / PASCAL / CRFPRN.ZIP / CRFPRN.PAS
Encoding:
Pascal/Delphi Source File  |  1985-12-28  |  1.5 KB  |  77 lines

  1. (*
  2.  * crfprn - print formatting filter for use with pcrf
  3.  *
  4.  * does not output repeated lines;
  5.  * only outputs changed portion of changed lines
  6.  * outputs count of duplicate lines
  7.  *
  8.  * shs 23-aug-85
  9.  *
  10.  *)
  11.  
  12. {$g10240,p128,d-,c-}
  13.  
  14. type
  15.    anystring = string[132];
  16.  
  17. var
  18.    line:   anystring;
  19.    pline:  anystring;
  20.    oline:  anystring;
  21.    dupcnt: integer;
  22.    i:      integer;
  23.    c:      char;
  24.  
  25.  
  26. begin
  27.    line := '';
  28.    pline := '<<start>>';
  29.    dupcnt := 1;
  30.  
  31.    repeat
  32.       oline := pline;
  33.       pline := line;
  34.       if eof then
  35.          line := '<<eof>>'
  36.       else
  37.          repeat
  38.             readln(line);
  39.          until (copy(line,41,40) <> copy(line,1,length(copy(line,41,40))))
  40.                or eof(input);
  41.  
  42.  
  43.       (* if lines are the same, then count this as a cuplicate line *)
  44.       if line = pline then
  45.          dupcnt := dupcnt + 1
  46.  
  47.       else
  48.       begin
  49.          (* output the duplicate count if needed *)
  50.          if dupcnt > 1 then
  51.             write(' (',dupcnt, ' times)');
  52.  
  53.          writeln;
  54.  
  55.          if (copy(line,1,40) <> copy(pline,1,40)) then
  56.          begin
  57.             writeln;
  58.             writeln('------------------------------------------------------');
  59.             write(copy(line,1,40));
  60.          end
  61.          else
  62.             write(' ':40);
  63.  
  64.          write(copy(line,41,40));
  65.          dupcnt := 1;
  66.       end;
  67.  
  68.       if keypressed then
  69.       begin
  70.          read(kbd,c);
  71.          if c = ^C then halt;
  72.       end;
  73.  
  74.    until eof;
  75.    writeln;
  76. end.
  77.