lines.pp 1.6 KB

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