program statistics; { Count characters and lines in a text file. Written by John Barr. Modified 28 Mar 79 by Bill Heidebrecht. } var charcount: integer; linecount: integer; charoverflow: integer; ch: char; source: text; procedure incrcharacter; begin charcount := charcount +1; if charcount = 10000 then begin charcount := 0; charoverflow := charoverflow +1 end end {incrcharacter}; procedure writedoubleint(high, low: integer); begin if high = 0 then write(low:10) else write(high:6, ((low div 1000) mod 10), ((low div 100) mod 10), ((low div 10) mod 10), (low mod 10)) end {writedoubleint}; begin {statistics} charcount := 0; linecount := 0; charoverflow := 0; reset(source, argv[1]@); while not eof(source) do begin ch := source@; get(source); if eoln(source) then linecount := linecount +1; incrcharacter end; writeln; writedoubleint(charoverflow, charcount); writeln(' characters,'); writeln(linecount:10, ' lines.') end.