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

%include 'isq.pas'

var
   db : t1file;
   f1 : integer;
   f2 : pstr;

begin
   writeln('content-type: text/html');
   writeln('');
   writeln('<html>');
   writeln('<head>');
   writeln('<title>CGI - Pascal</title>');
   writeln('</head>');
   writeln('<body>');
   writeln('<h1>CGI - Pascal</body>');
   writeln('<h2>Show:</h2>');
   writeln('<table border="1">');
   writeln('<tr>');
   writeln('<th>F1</th>');
   writeln('<th>F2</th>');
   writeln('</tr>');
   open(db, 'disk5:[cgi.apache]db.isq', old, organization := indexed, access_method := keyed);
   reset(db);
   while not(eof(db)) do begin
      f1 := db^.f1;
      f2 := trim(db^.f2);
      writeln('<tr>');
      writeln('<td>', f1:1, '</td>');
      writeln('<td>', f2, '</td>');
      writeln('<td><a href="/cgi-bin/isqdel?f1=', f1:1, '">Delete</a></td>');
      writeln('</tr>');
      get(db);
   end;
   close(db);
   writeln('</table>');
   writeln('<h2>Add:</h2>');
   writeln('<form method="post" action="/cgi-bin/isqadd">');
   writeln('F1: <input type="text" name="f1">');
   writeln('<br>');
   writeln('F2: <input type="text" name="f2">');
   writeln('<br>');
   writeln('<input type="submit" value="Add">');
   writeln('</form>');
   writeln('</body>');
   writeln('</html>');
end.
