Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
121
Task/Create-an-HTML-table/NetRexx/create-an-html-table-1.netrexx
Normal file
121
Task/Create-an-HTML-table/NetRexx/create-an-html-table-1.netrexx
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
/* NetRexx */
|
||||
options replace format comments java crossref symbols nobinary
|
||||
|
||||
-- create some test data. Put the data in a Rexx indexed string
|
||||
maxI = 1000
|
||||
rng = Random()
|
||||
xyz = ''
|
||||
xyz[0] = 1; xyz[1] = '. X Y Z' -- use a dot to indicate an empty cell
|
||||
loop r_ = 1 for 5
|
||||
ra = r_ rng.nextInt(maxI) rng.nextInt(maxI) rng.nextInt(maxI)
|
||||
xyz[0] = r_ + 1; xyz[r_ + 1] = ra
|
||||
end r_
|
||||
|
||||
-- build an HTML string
|
||||
html = htmlHeader()
|
||||
html = html || htmlTable(xyz)
|
||||
html = html || htmlFooter()
|
||||
|
||||
-- display HTML at standard output device
|
||||
say html
|
||||
|
||||
return
|
||||
|
||||
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
-- HTML boilerplate header
|
||||
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
method htmlHeader() public static returns Rexx
|
||||
html = '<?xml version="1.0" encoding="UTF-8"?>\n' -
|
||||
|| '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n' -
|
||||
|| '<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">\n' -
|
||||
|| '<head>\n' -
|
||||
|| '<meta http-equiv="Content-type" content="text/html;charset=UTF-8"/>\n' -
|
||||
|| '<title>RCreateHTMLTable</title>\n' -
|
||||
|| '<style type="text/css">\n' -
|
||||
|| '<!--\n' -
|
||||
|| '/* <![DATA[ */\n' -
|
||||
|| 'body {font-family: "Lucida Grande", "Geneva", "Verdana", "Helvetica Neue", "Helvetica", "DejaVu Sans", "Arial", sans-serif;}\n' -
|
||||
|| 'table, th, td {table-layout: fixed; border: 1px solid black; border-collapse: collapse; padding: 0.25em; font-size: 85%;}\n' -
|
||||
|| 'th, td {width: 6em;}\n' -
|
||||
|| 'th {color: white; background-color: green;}\n' -
|
||||
|| 'td {text-align: right;}\n' -
|
||||
|| 'p.classname {\n' -
|
||||
|| ' font-size: inherit;\n' -
|
||||
|| '}\n' -
|
||||
|| '/* ]] */\n' -
|
||||
|| '//-->\n' -
|
||||
|| '</style>\n' -
|
||||
|| '</head>\n' -
|
||||
|| '<body>\n' -
|
||||
|| '<h1>Rosetta Code – NetRexx Sample Output</h2>\n' -
|
||||
|| '<h2><a href="http://rosettacode.org/wiki/Create_an_HTML_table">Create an HTML table</a></h2>\n' -
|
||||
|| ''
|
||||
|
||||
return html
|
||||
|
||||
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
-- HTML footer
|
||||
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
method htmlFooter() public static returns Rexx
|
||||
html = '</body>\n' -
|
||||
|| '</html>\n' -
|
||||
|| ''
|
||||
return html
|
||||
|
||||
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
-- Create the table
|
||||
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
method htmlTable(rows, caption = '') public static returns Rexx
|
||||
html = '<table>\n'
|
||||
if caption.length() > 0 then do
|
||||
html = html -
|
||||
|| '<caption>'caption'</caption>\n' -
|
||||
|| '<thead>\n' -
|
||||
|| ''
|
||||
end
|
||||
html = html -
|
||||
|| htmlCsvTableRow(rows[1], 'th')'\n' -
|
||||
|| '</thead>\n' -
|
||||
|| '<tbody>\n' -
|
||||
|| ''
|
||||
loop r_ = 2 to rows[0]
|
||||
html = html -
|
||||
|| htmlCsvTableRow(rows[r_])
|
||||
end r_
|
||||
html = html -
|
||||
|| '</tbody>\n' -
|
||||
|| '</table>\n' -
|
||||
|| ''
|
||||
return html
|
||||
|
||||
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
-- Add a row to the table
|
||||
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
method htmlCsvTableRow(row, tag = 'td', sep = ' ', emptyCell = '.') public static returns Rexx
|
||||
if tag = null then tag = 'td'
|
||||
row = row.strip('t')
|
||||
-- replace HTML special characters with symbol entities
|
||||
row = row.changestr('&', '&') -- need to do this one first to avoid double translation
|
||||
row = row.changestr('"', '"')
|
||||
row = row.changestr("'", ''')
|
||||
row = row.changestr('<', '<')
|
||||
row = row.changestr('>', '>')
|
||||
elmts = ''
|
||||
elmts[0] = 0
|
||||
e_ = 0
|
||||
loop while row.length() > 0
|
||||
parse row elmt (sep) row
|
||||
if elmt == emptyCell then elmt = ' ' -- replace empy cells with non-breaking spaces
|
||||
e_ = e_ + 1; elmts[0] = e_; elmts[e_] = elmt
|
||||
end
|
||||
html = '<tr>\n' -
|
||||
|| ''
|
||||
loop e_ = 1 to elmts[0]
|
||||
html = html -
|
||||
|| '<'tag'>'elmts[e_]'</'tag'>\n' -
|
||||
|| ''
|
||||
end e_
|
||||
html = html -
|
||||
|| '</tr>\n' -
|
||||
|| ''
|
||||
return html
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
|
||||
<head>
|
||||
<meta http-equiv="Content-type" content="text/html;charset=UTF-8"/>
|
||||
<title>RCreateHTMLTable</title>
|
||||
<style type="text/css">
|
||||
<!--
|
||||
/* <![DATA[ */
|
||||
body {font-family: "Lucida Grande", "Geneva", "Verdana", "Helvetica Neue", "Helvetica", "DejaVu Sans", "Arial", sans-serif;}
|
||||
table, th, td {table-layout: fixed; border: 1px solid black; border-collapse: collapse; padding: 0.25em; font-size: 85%;}
|
||||
th, td {width: 6em;}
|
||||
th {color: white; background-color: green;}
|
||||
td {text-align: right;}
|
||||
p.classname {
|
||||
font-size: inherit;
|
||||
}
|
||||
/* ]] */
|
||||
//-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Rosetta Code – NetRexx Sample Output</h2>
|
||||
<h2><a href="http://rosettacode.org/wiki/Create_an_HTML_table">Create an HTML table</a></h2>
|
||||
<table>
|
||||
<tr>
|
||||
<th> </th>
|
||||
<th>X</th>
|
||||
<th>Y</th>
|
||||
<th>Z</th>
|
||||
</tr>
|
||||
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>1</td>
|
||||
<td>626</td>
|
||||
<td>128</td>
|
||||
<td>386</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>2</td>
|
||||
<td>985</td>
|
||||
<td>568</td>
|
||||
<td>636</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>3</td>
|
||||
<td>639</td>
|
||||
<td>622</td>
|
||||
<td>591</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>4</td>
|
||||
<td>843</td>
|
||||
<td>268</td>
|
||||
<td>436</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>5</td>
|
||||
<td>132</td>
|
||||
<td>526</td>
|
||||
<td>251</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue