(* Collection of code snippets by Arne Vajhøj *)
(* (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) *)
[inherit('sys$library:pascal$lib_routines')]
program Read2(input, output);

type
    string = varying[32767] of char;

procedure test(fnm : string);

var
  f : text;
  line : string;
  t1, t2 : Cardinal;
  n : integer;

begin
  t1 := Clock;
  open(f, fnm, old);
  reset(f);
  n := 0;
  while not eof(f) do begin
    readln(f, line);
    n := n + 1;
  end;
  writeln(n:1,' lines');
  close(f);
  t2 := Clock;
  writeln('Read one line at a time : ', (t2 - t1):1, ' ms');
end;

var
  i : integer;
  cmdlin : string;

begin
  lib$get_foreign(resultant_string:=cmdlin.body,resultant_length:=cmdlin.length);
  for i := 1 to 3 do begin
    test(cmdlin);
  end;
end.

