Create an HTML table.

 The table body should have at least three rows of three columns.
 Each of these three columns should be labelled "X", "Y", and "Z". 
 An extra column should be added at either the extreme left or the extreme right of the table that has no heading, but is filled with sequential row numbers. 
 The rows of the "X", "Y", and "Z" columns should be filled with random or sequential integers having 4 digits or less. 
 The numbers should be aligned in the same fashion for all columns.


MODULE testCGI;
 
FROM  InOut       IMPORT  WriteCard, WriteLn, WriteString, WriteBf;
FROM  Arguments   IMPORT  ArgTable, GetEnv;
FROM  Strings     IMPORT  Assign, Length, String;
 
VAR  EnvVars             : ArgTable;
 
PROCEDURE ReadEnvVar;
 
VAR   Value          : String;
      i              : CARDINAL;
 
BEGIN
   WriteString ('<table border="1" cellpadding="4" width="80%" align="center">');
   WriteString ('<tr><th>Index</th><th>Length</th><th>Content</th></tr>');
   i := 0;
   LOOP
      IF  EnvVars^ [i] = NIL  THEN  EXIT  END;
      Assign (Value, EnvVars^ [i]^);
      WriteString ('<tr><td align="center">');
      WriteCard (i, 2);
      WriteString ('</td><td align="center">');
      WriteCard (Length (Value), 3);
      WriteString ('</td><td>');    WriteString (Value);
      WriteString ("</td></tr>");
      WriteLn;
      INC (i)
   END;
   WriteString("</table>");
END ReadEnvVar;
 
BEGIN
   GetEnv (EnvVars);
   WriteString ('Content-type:text/html');
   WriteLn;
   WriteLn;
   WriteString ('<html><head>');
   WriteString ('<title>CGI with the Mocka Modula-2 compiler</title>');
   WriteString ('</head><body>');
   WriteLn;
   WriteString ('<center><h2>CGI environment passed along by your browser</h2></center><p>');
   ReadEnvVar;
   WriteString ('</body></html>');
   WriteLn;
   WriteBf
END testCGI.