RosettaCodeData/Task/CSV-to-HTML-translation/BBC-BASIC/csv-to-html-translation.basic
2023-07-01 13:44:08 -04:00

42 lines
1.3 KiB
Text

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 "&lt;";
WHEN ">": PRINT "&gt;";
WHEN "&": PRINT "&amp;";
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