Create an HTML table: Difference between revisions

Content added Content deleted
Line 1,038: Line 1,038:
: > [char] > emit space ; \ output the '>' output text upto next tag
: > [char] > emit space ; \ output the '>' output text upto next tag


\ Create our HTML extensions to the Forth interpreter
\ Create some HTML extensions to the Forth interpreter
: <table> ." <table>" cr ; : </table> ." </table>" cr ;
: <table> ." <table>" cr ; : </table> ." </table>" cr ;
: <table ." <table " ;
: <table ." <table " ;
: style=" ." style=" toquote space ;
: style=" ." style=" toquote ;
: align=" ." align=" toquote ;
: align=" ." align=" toquote ;
: border=" ." border=" toquote ;
: border=" ." border=" toquote ;
: width=" ." width=" toquote ;
: width=" ." width=" toquote ;
: cellspacing=" ." cellspacing=" toquote ;
: cellspacing=" ." cellspacing=" toquote ;
: colspacing=" ." colspacing=" toquote ;
: colspacing=" ." colspacing=" toquote ;


: <tr> ." <tr>" cr ; : </tr> ." </tr>" cr ;
: <tr> ." <tr>" cr ; : </tr> ." </tr>" cr ;
: <td> ." <td> " totag ; : </td> ." </td>" cr ;
: <td> ." <td> " totag ; : </td> ." </td>" cr ;
: <td ." <td " ;
: <td ." <td " ;
Line 1,088: Line 1,088:
</lang>
</lang>
{{Output}}
{{Output}}
<pre>
<table border="1" width="30%" >
<caption>This table was created with FORTH HTML tags</caption>
<tr>
<th align="right" > </th>
<th align="right" > A</th>
<th align="right" > B</th>
<th align="right" > C</th>
</tr>
<tr>
<th align="right" > 1 </th>
<td align="right" > 338 </td>
<td align="right" > 102 </td>
<td align="right" > 113 </td>
</tr>
<tr>
<th align="right" > 2 </th>
<td align="right" > 430 </td>
<td align="right" > 319 </td>
<td align="right" > 731 </td>
</tr>
<tr>
<th align="right" > 3 </th>
<td align="right" > 333 </td>
<td align="right" > 592 </td>
<td align="right" > 83 </td>
</tr>
</table> </pre>

===Result===
<table border="1" width="30%" >
<table border="1" width="30%" >
<caption>This table was created with FORTH HTML tags</caption>
<caption>This table was created with FORTH HTML tags</caption>