(* Collection of code snippets by Arne Vajhøj *)
(* (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) *)
program isqadd(input, output);

%include 'isq.pas'

const
   EXTRA = chr(13) + chr(10);

var
   db : t1file;
   f : text;
   line : varying [1000] of char;
   ix1, ix2 : integer;
   form_f1, form_f2 : varying [255] of char;
   f1 : integer;
   f2 : pstr;

begin
   open(f, 'apache$input', old);
   reset(f);
   readln(f, line);
   close(f);
   ix1 := index(line, 'f1=') + 3;
   ix2 := index(line + '&', '&');
   form_f1 := substr(line, ix1, ix2 - ix1);
   readv(form_f1, f1);
   line := substr(line, ix2 + 1, line.length - ix2);
   ix1 := index(line, 'f2=') + 3;
   ix2 := index(line + '&', '&');
   form_f2 := substr(line, ix1, ix2 - ix1);
   f2 := form_f2;
   open(db, 'disk5:[cgi.apache]db.isq', old, organization := indexed, access_method := keyed);
   reset(db);
   db^.f1 := f1;
   db^.f2 := f2;
   put(db);
   close(db);
   writeln('Location: http://arne1.vajhoej.dk/cgi-bin/isqshow', EXTRA);
   writeln(EXTRA);
end.
