Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
55
Task/Create-an-HTML-table/Agena/create-an-html-table.agena
Normal file
55
Task/Create-an-HTML-table/Agena/create-an-html-table.agena
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
notNumbered := 0; # possible values for html table row numbering
|
||||
numberedLeft := 1; # " " " " " " "
|
||||
numberedRight := 2; # " " " " " " "
|
||||
|
||||
alignCentre := 0; # possible values for html table column alignment
|
||||
alignLeft := 1; # " " " " " " "
|
||||
alignRight := 2; # " " " " " " "
|
||||
|
||||
# write an html table to a file
|
||||
writeHtmlTable := proc( fh, t :: table ) is
|
||||
local align := "align='";
|
||||
case t.columnAlignment
|
||||
of alignLeft then align := align & "left'"
|
||||
of alignRight then align := align & "right'"
|
||||
else align := align & "center'"
|
||||
esac;
|
||||
local put := proc( text :: string ) is io.write( fh, text & "\n" ) end;
|
||||
local thElement := proc( content :: string ) is put( "<th " & align & ">" & content & "</th>" ) end;
|
||||
local tdElement := proc( content ) is put( "<td " & align & ">" & content & "</td>" ) end;
|
||||
# table element
|
||||
put( "<table"
|
||||
& " cellspacing='" & t.cellSpacing & "'"
|
||||
& " colspacing='" & t.colSpacing & "'"
|
||||
& " border='" & t.border & "'"
|
||||
& ">"
|
||||
);
|
||||
# table headings
|
||||
put( "<tr>" );
|
||||
if t.rowNumbering = numberedLeft then thElement( "" ) fi;
|
||||
for col to size t.headings do thElement( t.headings[ col ] ) od;
|
||||
if t.rowNumbering = numberedRight then thElement( "" ) fi;
|
||||
put( "</tr>" );
|
||||
# table rows
|
||||
for row to size t.data do
|
||||
put( "<tr>" );
|
||||
if t.rowNumbering = numberedLeft then thElement( row & "" ) fi;
|
||||
for col to size t.data[ row ] do tdElement( t.data[ row, col ] ) od;
|
||||
if t.rowNumbering = numberedRight then thElement( row & "" ) fi;
|
||||
put( "</tr>" )
|
||||
od;
|
||||
# end of table
|
||||
put( "</table>" )
|
||||
end ;
|
||||
|
||||
# create an html table and print it to standard output
|
||||
scope
|
||||
local t := [];
|
||||
t.cellSpacing, t.colSpacing := 0, 0;
|
||||
t.border := 1;
|
||||
t.columnAlignment := alignRight;
|
||||
t.rowNumbering := numberedLeft;
|
||||
t.headings := [ "A", "B", "C" ];
|
||||
t.data := [ [ 1001, 1002, 1003 ], [ 21, 22, 23 ], [ 201, 202, 203 ] ];
|
||||
writeHtmlTable( io.stdout, t )
|
||||
epocs
|
||||
Loading…
Add table
Add a link
Reference in a new issue