CSV to HTML translation: Difference between revisions
Content added Content deleted
No edit summary |
(Added BBC BASIC) |
||
Line 230: | Line 230: | ||
<tr><td>The multitude</td><td>Behold his mother! Behold his mother!</td></tr> |
<tr><td>The multitude</td><td>Behold his mother! Behold his mother!</td></tr> |
||
</table></pre>(note the output has been modified slightly since this webpage is html.) |
</table></pre>(note the output has been modified slightly since this webpage is html.) |
||
=={{header|BBC BASIC}}== |
|||
{{works with|BBC BASIC for Windows}} |
|||
<lang bbcbasic> DATA "Character,Speech" |
|||
DATA "The multitude,The messiah! Show us the messiah!" |
|||
DATA "Brian's mother,<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>" |
|||
DATA "The multitude,Who are you?" |
|||
DATA "Brian's mother,I'm his mother; that's who!" |
|||
DATA "The multitude,Behold his mother! Behold his mother!" |
|||
DATA "***" |
|||
*SPOOL CSVtoHTML.htm |
|||
PRINT "<HTML>" |
|||
PRINT "<HEAD>" |
|||
PRINT "</HEAD>" |
|||
PRINT "<BODY>" |
|||
PRINT "<table border=1 cellpadding =10 cellspacing=0>" |
|||
header% = TRUE |
|||
REPEAT |
|||
READ csv$ |
|||
IF csv$ = "***" THEN EXIT REPEAT |
|||
IF header% PRINT "<tr><th>"; ELSE PRINT "<tr><td>"; |
|||
FOR i% = 1 TO LEN(csv$) |
|||
c$ = MID$(csv$, i%, 1) |
|||
CASE c$ OF |
|||
WHEN ",": IF header% PRINT "</th><th>"; ELSE PRINT "</td><td>"; |
|||
WHEN "<": PRINT "<"; |
|||
WHEN ">": PRINT ">"; |
|||
WHEN "&": PRINT "&"; |
|||
OTHERWISE: PRINT c$; |
|||
ENDCASE |
|||
NEXT i% |
|||
IF header% PRINT "</th></tr>" ELSE PRINT "</td></tr>" |
|||
header% = FALSE |
|||
UNTIL FALSE |
|||
PRINT "</table>" |
|||
PRINT "</BODY>" |
|||
PRINT "</HTML>" |
|||
*spool |
|||
SYS "ShellExecute", @hwnd%, 0, "CSVtoHTML.htm", 0, 0, 1 |
|||
</lang> |
|||
Output: |
|||
<pre><HTML> |
|||
<HEAD> |
|||
</HEAD> |
|||
<BODY> |
|||
<table border=1 cellpadding =10 cellspacing=0> |
|||
<tr><th>Character</th><th>Speech</th></tr> |
|||
<tr><td>The multitude</td><td>The messiah! Show us the messiah!</td></tr> |
|||
<tr><td>Brian's mother</td><td><angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry></td></tr> |
|||
<tr><td>The multitude</td><td>Who are you?</td></tr> |
|||
<tr><td>Brian's mother</td><td>I'm his mother; that's who!</td></tr> |
|||
<tr><td>The multitude</td><td>Behold his mother! Behold his mother!</td></tr> |
|||
</table> |
|||
</BODY> |
|||
</HTML></pre> |
|||
Rendered output: |
|||
[[File:CSVHTML_BBC.gif]] |
|||
=={{header|C}}== |
=={{header|C}}== |