September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -0,0 +1,63 @@
|
|||
* Create an HTML table 19/02/2017
|
||||
CREHTML CSECT
|
||||
USING CREHTML,R13
|
||||
B 72(R15)
|
||||
DC 17F'0'
|
||||
STM R14,R12,12(R13)
|
||||
ST R13,4(R15)
|
||||
ST R15,8(R13)
|
||||
LR R13,R15 end of prolog
|
||||
LA R8,RND
|
||||
XPRNT PGBODY,64 <html><head></head><body>
|
||||
XPRNT PGTAB,64 <table border=1 ... cellspacing=0>
|
||||
SR R6,R6 row=0
|
||||
DO WHILE=(C,R6,LE,NROWS) do row=0 to nrows
|
||||
IF LTR,R6,Z,R6 THEN if row=0
|
||||
XPRNT PGTRTH,64 <tr><th></th>
|
||||
ELSE , else
|
||||
XDECO R6,XDEC edit row
|
||||
MVC PGTR+8(1),XDEC+11 output row heading
|
||||
XPRNT PGTR,64 <tr><th>.</th>
|
||||
ENDIF , endif
|
||||
LA R7,1 col=1
|
||||
DO WHILE=(C,R7,LE,NCOLS) do col=1 to ncols
|
||||
IF LTR,R6,Z,R6 THEN if row=0
|
||||
LR R1,R7 col
|
||||
LA R4,TCAR-1(R1) tcar(col)
|
||||
MVC PGTH+4(1),0(R4) output heading
|
||||
XPRNT PGTH,64 <th>.</th>
|
||||
ELSE , else
|
||||
L R2,0(R8) value
|
||||
XDECO R2,XDEC edit value
|
||||
MVC PGTD+18(4),XDEC+8 output cell value
|
||||
XPRNT PGTD,64 <td align="right">....</td>
|
||||
LA R8,4(R8) next value
|
||||
ENDIF , endif
|
||||
LA R7,1(R7) col++
|
||||
ENDDO , enddo col
|
||||
XPRNT PGETR,64 </tr>
|
||||
LA R6,1(R6) row++
|
||||
ENDDO , enddo row
|
||||
XPRNT PGETAB,64 </table>
|
||||
XPRNT PGEBODY,64 </body></html>
|
||||
L R13,4(0,R13) epilog
|
||||
LM R14,R12,12(R13)
|
||||
XR R15,R15
|
||||
BR R14 exit
|
||||
NROWS DC F'4' number of rows
|
||||
NCOLS DC F'3' number of columns
|
||||
TCAR DC CL3'XYZ'
|
||||
RND DC F'7055',F'5334',F'5795',F'2895',F'3019',F'7747'
|
||||
DC F'140',F'7607',F'8144',F'7090',F'475',F'4140'
|
||||
PGBODY DC CL64'<html><head></head><body>'
|
||||
PGTAB DC CL64'<table border=1 cellpadding=10 cellspacing=0>'
|
||||
PGTRTH DC CL64'<tr><th></th>'
|
||||
PGTH DC CL64'<th>.</th>'
|
||||
PGETR DC CL64'</tr>'
|
||||
PGTR DC CL64'<tr><th>.</th>'
|
||||
PGTD DC CL64'<td align="right">....</td>'
|
||||
PGETAB DC CL64'</table>'
|
||||
PGEBODY DC CL64'</body></html>'
|
||||
XDEC DS CL12
|
||||
YREGS
|
||||
END CREHTML
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
#!/usr/bin/awk -f
|
||||
BEGIN {
|
||||
print "<table>\n <thead align = \"right\">"
|
||||
printf " <tr><th></th><td>X</td><td>Y</td><td>Z</td></tr>\n </thead>\n <tbody align = \"right\">\n"
|
||||
for (i=1; i<=10; i++) {
|
||||
printf " <tr><td>%2i</td><td>%5i</td><td>%5i</td><td>%5i</td></tr>\n",i, 10*i, 100*i, 1000*i-1
|
||||
}
|
||||
print " </tbody>\n</table>\n"
|
||||
}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
<table>
|
||||
<thead align = "right">
|
||||
<tr><th></th><td>X</td><td>Y</td><td>Z</td></tr>
|
||||
</thead>
|
||||
<tbody align = "right">
|
||||
<tr><td> 1</td><td> 10</td><td> 100</td><td> 999</td></tr>
|
||||
<tr><td> 2</td><td> 20</td><td> 200</td><td> 1999</td></tr>
|
||||
<tr><td> 3</td><td> 30</td><td> 300</td><td> 2999</td></tr>
|
||||
<tr><td> 4</td><td> 40</td><td> 400</td><td> 3999</td></tr>
|
||||
<tr><td> 5</td><td> 50</td><td> 500</td><td> 4999</td></tr>
|
||||
<tr><td> 6</td><td> 60</td><td> 600</td><td> 5999</td></tr>
|
||||
<tr><td> 7</td><td> 70</td><td> 700</td><td> 6999</td></tr>
|
||||
<tr><td> 8</td><td> 80</td><td> 800</td><td> 7999</td></tr>
|
||||
<tr><td> 9</td><td> 90</td><td> 900</td><td> 8999</td></tr>
|
||||
<tr><td>10</td><td> 100</td><td> 1000</td><td> 9999</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
:: It's easier and neater to create the variables holding the random 4 digit numbers ahead of time
|
||||
for /l %%i in (1,1,12) do set /a rand%%i=!random! %% 9999
|
||||
|
||||
:: The command output of everything within the brackets is sent to the file "table.html", overwriting anything already in there
|
||||
(
|
||||
echo ^<html^>^<head^>^</head^>^<body^>
|
||||
echo ^<table border=1 cellpadding=10 cellspacing=0^>
|
||||
echo ^<tr^>^<th^>^</th^>
|
||||
echo ^<th^>X^</th^>
|
||||
echo ^<th^>Y^</th^>
|
||||
echo ^<th^>Z^</th^>
|
||||
echo ^</tr^>
|
||||
echo ^<tr^>^<th^>1^</th^>
|
||||
echo ^<td align="right"^>%rand1%^</td^>
|
||||
echo ^<td align="right"^>%rand2%^</td^>
|
||||
echo ^<td align="right"^>%rand3%^</td^>
|
||||
echo ^</tr^>
|
||||
echo ^<tr^>^<th^>2^</th^>
|
||||
echo ^<td align="right"^>%rand4%^</td^>
|
||||
echo ^<td align="right"^>%rand5%^</td^>
|
||||
echo ^<td align="right"^>%rand6%^</td^>
|
||||
echo ^</tr^>
|
||||
echo ^<tr^>^<th^>3^</th^>
|
||||
echo ^<td align="right"^>%rand7%^</td^>
|
||||
echo ^<td align="right"^>%rand8%^</td^>
|
||||
echo ^<td align="right"^>%rand9%^</td^>
|
||||
echo ^</tr^>
|
||||
echo ^<tr^>^<th^>4^</th^>
|
||||
echo ^<td align="right"^>%rand10%^</td^>
|
||||
echo ^<td align="right"^>%rand11%^</td^>
|
||||
echo ^<td align="right"^>%rand12%^</td^>
|
||||
echo ^</tr^>
|
||||
echo ^</table^>
|
||||
echo ^</body^>^</html^>
|
||||
) > table.html
|
||||
start table.html
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
defmodule Table do
|
||||
defp put_rows(n) do
|
||||
Enum.map_join(1..n, fn i ->
|
||||
"<tr align=right><th>#{i}</th>" <>
|
||||
Enum.map_join(1..3, fn _ ->
|
||||
"<td>#{:rand.uniform(2000)}</td>"
|
||||
end) <> "</tr>\n"
|
||||
end)
|
||||
end
|
||||
|
||||
def create_table(n\\3) do
|
||||
"<table border=1>\n" <>
|
||||
"<th></th><th>X</th><th>Y</th><th>Z</th>\n" <>
|
||||
put_rows(n) <>
|
||||
"</table>"
|
||||
end
|
||||
end
|
||||
|
||||
IO.puts Table.create_table
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<table border=1>
|
||||
<th></th><th>X</th><th>Y</th><th>Z</th>
|
||||
<tr align=right><th>1</th><td>1362</td><td>1289</td><td>357</td></tr>
|
||||
<tr align=right><th>2</th><td>1161</td><td>1345</td><td>1176</td></tr>
|
||||
<tr align=right><th>3</th><td>391</td><td>62</td><td>609</td></tr>
|
||||
</table>
|
||||
|
|
@ -1,20 +1,27 @@
|
|||
#!/usr/bin/runhaskell
|
||||
|
||||
import Data.List (unfoldr)
|
||||
import Control.Monad (forM_)
|
||||
import System.Random
|
||||
import Data.List as L
|
||||
|
||||
import Text.Blaze.Html5
|
||||
import Text.Blaze.Html.Renderer.Pretty
|
||||
import qualified Text.Blaze.Html5 as B
|
||||
import Text.Blaze.Html.Renderer.Pretty (renderHtml)
|
||||
|
||||
makeTable :: RandomGen g => [String] -> Int -> g -> Html
|
||||
import System.Random (RandomGen, getStdGen, randomRs, split)
|
||||
|
||||
makeTable
|
||||
:: RandomGen g
|
||||
=> [String] -> Int -> g -> B.Html
|
||||
makeTable headings nRows gen =
|
||||
table $ do
|
||||
thead $ tr $ forM_ (L.map toHtml headings) th
|
||||
tbody $ forM_ (zip [1 .. nRows] $ unfoldr (Just . split) gen)
|
||||
(\(x,g) -> tr $ forM_ (take (length headings)
|
||||
(x:randomRs (1000,9999) g)) (td . toHtml))
|
||||
B.table $
|
||||
do B.thead $ B.tr $ forM_ (B.toHtml <$> headings) B.th
|
||||
B.tbody $
|
||||
forM_
|
||||
(zip [1 .. nRows] $ unfoldr (Just . split) gen)
|
||||
(\(x, g) ->
|
||||
B.tr $
|
||||
forM_
|
||||
(take (length headings) (x : randomRs (1000, 9999) g))
|
||||
(B.td . B.toHtml))
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
g <- getStdGen
|
||||
putStrLn $ renderHtml $ makeTable ["", "X", "Y", "Z"] 3 g
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
// version 1.1.3
|
||||
|
||||
import java.util.Random
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val r = Random()
|
||||
val sb = StringBuilder()
|
||||
val i = " " // indent
|
||||
with (sb) {
|
||||
append("<html>\n<head>\n")
|
||||
append("<style>\n")
|
||||
append("table, th, td { border: 1px solid black; }\n")
|
||||
append("th, td { text-align: right; }\n")
|
||||
append("</style>\n</head>\n<body>\n")
|
||||
append("<table style=\"width:60%\">\n")
|
||||
append("$i<thead>\n")
|
||||
append("$i$i<tr><th></th>")
|
||||
for (c in 'X'..'Z') append("<th>$c</th>")
|
||||
append("</tr>\n")
|
||||
append("$i</thead>\n")
|
||||
append("$i<tbody>\n")
|
||||
val f = "$i$i<tr><td>%d</td><td>%d</td><td>%d</td><td>%d</td></tr>\n"
|
||||
for (j in 1..4) {
|
||||
append(f.format(j, r.nextInt(10000), r.nextInt(10000), r.nextInt(10000)))
|
||||
}
|
||||
append("$i</tbody>\n")
|
||||
append("</table>\n")
|
||||
append("</body>\n</html>")
|
||||
}
|
||||
println(sb.toString())
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<html>
|
||||
<head>
|
||||
<style>
|
||||
table, th, td { border: 1px solid black; }
|
||||
th, td { text-align: right; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table style="width:60%">
|
||||
<thead>
|
||||
<tr><th></th><th>X</th><th>Y</th><th>Z</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr><td>1</td><td>1444</td><td>3451</td><td>2568</td></tr>
|
||||
<tr><td>2</td><td>876</td><td>3866</td><td>824</td></tr>
|
||||
<tr><td>3</td><td>2710</td><td>3845</td><td>8089</td></tr>
|
||||
<tr><td>4</td><td>6480</td><td>7885</td><td>9246</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
<@ SDCLIT>
|
||||
<@ DTBLIT>
|
||||
<@ DTRLITLIT>
|
||||
<@ DTDLITLIT>|[style]background-color:white</@>
|
||||
<@ DTD>X</@>
|
||||
<@ DTD>Y</@>
|
||||
<@ DTD>Z</@>|[style]width:100%; background-color:brown;color:white; text-align:center</@>
|
||||
<@ ITEFORLIT>10|
|
||||
<@ DTRLITCAP>
|
||||
<@ DTDPOSFORLIT>...|[style]background-color:Brown; color:white; text-align:right</@>
|
||||
<@ DTDCAPLIT><@ SAYR!ILI2>1|9999</@>|[style]width:50;text-align:right</@>
|
||||
<@ DTDCAPLIT><@ SAYR!ILI2>1|9999</@>|[style]width:50;text-align:right</@>
|
||||
<@ DTDCAPLIT><@ SAYR!ILI2>1|9999</@>|[style]width:50;text-align:right</@>
|
||||
|[style]background-color:white;color:black</@>
|
||||
</@>
|
||||
</@>
|
||||
|Number Table</@>
|
||||
21
Task/Create-an-HTML-table/Rust/create-an-html-table-1.rust
Normal file
21
Task/Create-an-HTML-table/Rust/create-an-html-table-1.rust
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
extern crate rand;
|
||||
|
||||
use rand::Rng;
|
||||
|
||||
fn random_cell() -> usize {
|
||||
// Anything between 0 and 10000 has 4 digits or less
|
||||
return rand::thread_rng().gen_range(0, 10000);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
println!("<table><thead><tr><th></th><td>X</td><td>Y</td><td>Z</td></tr></thead>");
|
||||
|
||||
for row in 0..3 {
|
||||
let x = random_cell();
|
||||
let y = random_cell();
|
||||
let z = random_cell();
|
||||
println!("<tr><th>{}</th><td>{}</td><td>{}</td><td>{}</td></tr>", row, x, y, z);
|
||||
}
|
||||
|
||||
println!("</table>");
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
<table><thead><tr><th></th><td>X</td><td>Y</td><td>Z</td></tr></thead>
|
||||
<tr><th>0</th><td>7101</td><td>9111</td><td>3446</td></tr>
|
||||
<tr><th>1</th><td>426</td><td>9518</td><td>611</td></tr>
|
||||
<tr><th>2</th><td>9693</td><td>419</td><td>4878</td></tr>
|
||||
</table>
|
||||
37
Task/Create-an-HTML-table/Stata/create-an-html-table-1.stata
Normal file
37
Task/Create-an-HTML-table/Stata/create-an-html-table-1.stata
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
program mat2html
|
||||
local nr = rowsof(`1')
|
||||
local nc = colsof(`1')
|
||||
local rn `: rownames `1''
|
||||
local cn `: colnames `1''
|
||||
tempname f
|
||||
qui file open `f' using `2', write text replace
|
||||
file write `f' "<!doctype html>" _n
|
||||
file write `f' "<html>" _n
|
||||
file write `f' "<head>" _n
|
||||
file write `f' `"<meta charset="UTF-8">"' _n
|
||||
file write `f' "</head>" _n
|
||||
file write `f' "<body>" _n
|
||||
file write `f' `"<table border="1">"' _n
|
||||
* write column names
|
||||
file write `f' "<tr>" _n
|
||||
file write `f' "<td></td>" _n
|
||||
forv j = 1/`nc' {
|
||||
local s `: word `j' of `cn''
|
||||
file write `f' `"<td>`s'</td>"' _n
|
||||
}
|
||||
file write `f' "</tr>" _n
|
||||
* write row names & data
|
||||
forv i = 1/`nr' {
|
||||
file write `f' "<tr>" _n
|
||||
local s `: word `i' of `rn''
|
||||
file write `f' `"<td>`s'</td>"' _n
|
||||
forv j = 1/`nc' {
|
||||
file write `f' `"<td>`=el(`1',`i',`j')'</td>"' _n
|
||||
}
|
||||
file write `f' "</tr>" _n
|
||||
}
|
||||
file write `f' "</table>" _n
|
||||
file write `f' "</body>" _n
|
||||
file write `f' "</html>" _n
|
||||
file close `f'
|
||||
end
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
matrix a=2,9,4\7,5,3\6,1,8
|
||||
matrix rownames a = A B C
|
||||
matrix colnames a = X Y Z
|
||||
mat2html a magic.html
|
||||
9
Task/Create-an-HTML-table/Zkl/create-an-html-table.zkl
Normal file
9
Task/Create-an-HTML-table/Zkl/create-an-html-table.zkl
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
table:=0'|<table style="text-align:center; border: 1px solid">|
|
||||
"<th></th><th>X</th><th>Y</th><th>Z</th><tr>";
|
||||
table=Sink(table);
|
||||
foreach n in ([1..3]){
|
||||
table.write("\n <tr><th>",n,"</th>");
|
||||
foreach n in (3){ table.write("<td>",(0).random(10000),"</td>"); }
|
||||
table.write("</tr>");
|
||||
}
|
||||
table.write("\n</table>\n").close().print();
|
||||
Loading…
Add table
Add a link
Reference in a new issue