RosettaCodeData/Task/Create-an-HTML-table/PL-I/create-an-html-table.pli

45 lines
1.1 KiB
Plaintext

/* Create an HTML table. 6/2011 */
create: procedure options (main);
create_table: procedure (headings, table_contents);
declare headings(*) character (10) varying;
declare table_contents(*, *) fixed;
declare (i, row, col) fixed;
put skip edit ('<table>') (a);
/* Headings. */
put skip edit ('<tr><th></th> ') (a);
/* For an empty column heading */
do i = 1 to hbound(headings);
put edit ('<th>', headings(i), '</th> ' ) (a);
end;
put edit ('</tr>') (a);
/* Table contents. */
do row = 1 to hbound(table_contents, 1);
/* row number */
put skip edit ('<tr><td>', row, '</td> ') (a);
/* row contents */
do col = 1 to hbound(table_contents, 2);
put edit ('<td>', table_contents(row, col), '</td> ' ) (a);
end;
put edit ('</tr>') (a);
end;
put skip edit ('</table>' ) (a);
end create_table;
declare headings (3) character (1) static initial ('X', 'Y', 'Z');
declare table_contents(3, 3) fixed static initial (
4, -3, 8,
7, 2, -6,
11, 1, 15);
call create_table (headings, table_contents);
end create;