(* 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 listperf(input,output);

%include 'util.pas'

%include 'perf.pas'

var
   p : perf;
   cmdlin : pstr;
   lim, i, ix, n : integer;

begin
   lib$get_foreign(resultant_string := cmdlin.body, resultant_length := cmdlin.length);
   readv(cmdlin, lim);
   open(perf_file, 'perf.isq', old, organization := indexed, access_method := keyed);
   reset(perf_file);
   seed(clock);
   n := 0;
   for i := 1 to lim do begin
      ix := 1 + trunc(99990 * random);
      findk(perf_file, 0, ix);
      while not(ufb(perf_file)) and (perf_file^.id < ix + 10) do begin
         p := perf_file^;
         n := n + 1;
         get(perf_file);
      end;
   end;
   writeln(n:1);
   close(perf_file);
end.
