home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / fpkbin99.zip / DEMOS / LINES.PAS < prev    next >
Pascal/Delphi Source File  |  1998-10-12  |  2KB  |  71 lines

  1. {
  2.   LINES.PP
  3.  
  4.   Program that counts number of Lines in a file
  5.  
  6.   Copyright (c) 1992,95 by FP Klämpfl
  7.   Translated By Eric Molitor (emolitor@freenet.fsu.edu)
  8.  
  9.   History:
  10.       29.10.1992       Version 1.0
  11.       3.3.1995         an FPKPascal angepaßt
  12. }
  13.  
  14. program count_lines;
  15.  
  16.   uses
  17.      dos,crt;
  18.  
  19.   type
  20.      td = array[1..10000] of byte;
  21.  
  22.   var
  23.      lines : longint;
  24.      s : searchrec;
  25.      f : file;
  26.      d : ^td;
  27. {$ifdef tp}
  28.      count : word;
  29.      i,z : integer;
  30. {$else}
  31.      count,i,z : longint;
  32. {$endif}
  33.  
  34.   begin
  35.      lines:=0;
  36.      new(d);
  37.      if paramcount<1 then
  38.        begin
  39.           writeln('Usage: LINES FILENAME.EXT [FILENAME.EXT] ...');
  40.           writeln('  Multiple File Names and Wild Cards Allowed:');
  41.           writeln('  z.B  LINES *.CPP STDIO.H *.ASM');
  42.           halt(1);
  43.        end;
  44.      for i:=1 to paramcount do
  45.        begin
  46.           findfirst(paramstr(i),archive,s);
  47.           while (doserror=0) do
  48.             begin
  49.                gotoxy(1,wherey);
  50.                write('                               ');
  51.                gotoxy(1,wherey);
  52.                write('Scanning: ',s.name);
  53.                assign(f,s.name);
  54.                reset(f,1);
  55.                while not(eof(f)) do
  56.                  begin
  57.                     blockread(f,d^,10000,count);
  58.                     for z:=1 to count do
  59.                       if d^[z]=10 then inc(lines);
  60.                  end;
  61.                close(f);
  62.                findnext(s);
  63.             end;
  64.        end;
  65.      dispose(d);
  66.      gotoxy(1,wherey);
  67.      write('                               ');
  68.      gotoxy(1,wherey);
  69.      if lines=1 then writeln('1 Line') else writeln(lines,' Lines');
  70.   end.
  71.