(* Collection of code snippets by Arne Vajhøj *)
(* (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) *)
[inherit('sys$library:starlet','sys$library:pascal$lib_routines')]

program isq2(input,output);

type
   string = varying [255] of char;
   fixstring = packed array [1..8] of char;
   isqrec = record
               keyfield  : [KEY(0)] fixstring;
               bodyfield : string;
            end;

var
   isqf : file of isqrec;
   tmp,fnm,rnm : string;
   k : fixstring;
   table,ix : integer;

begin
   table:=LIB$K_CLI_GLOBAL_SYM;
   lib$get_symbol('WWW_PATH_INFO',tmp.body,tmp.length,table);
   tmp:=substr(tmp,2,length(tmp)-1);
   ix:=index(tmp,'/');
   fnm:=substr(tmp,1,ix-1);
   rnm:=substr(tmp,ix+1,length(tmp)-ix);
   open(isqf,fnm,readonly,access_method:=keyed,organization:=indexed);
   resetk(isqf,0);
   writeln('content-type: text/html');
   writeln;
   writeln('<HTML>');
   writeln('<HEAD>');
   writeln('<TITLE>',fnm,'</TITLE>');
   writeln('</HEAD>');
   writeln('<BODY>');
   writeln('<PRE>');
   k:=rnm;
   findk(isqf,0,k);
   if not(ufb(isqf)) then begin
      writeln(isqf^.bodyfield);
   end else begin
      writeln('Record not found');
   end;
   writeln('</PRE>');
   writeln('</BODY>');
   writeln('</HTML>');
   close(isqf);
end.
