50 lines
1.5 KiB
Text
50 lines
1.5 KiB
Text
FUNCTION csvToHtml RETURNS CHARACTER (
|
|
i_lhas_header AS LOGICAL,
|
|
i_cinput AS CHARACTER
|
|
):
|
|
|
|
DEFINE VARIABLE coutput AS CHARACTER NO-UNDO.
|
|
|
|
DEFINE VARIABLE irow AS INTEGER NO-UNDO.
|
|
DEFINE VARIABLE icolumn AS INTEGER NO-UNDO.
|
|
DEFINE VARIABLE crow AS CHARACTER NO-UNDO.
|
|
DEFINE VARIABLE ccell AS CHARACTER NO-UNDO.
|
|
|
|
coutput = "<html>~n~t<table>".
|
|
|
|
DO irow = 1 TO NUM-ENTRIES( i_cinput, "~n":U ):
|
|
|
|
coutput = coutput + "~n~t~t<tr>".
|
|
|
|
crow = ENTRY( irow, i_cinput, "~n":U ).
|
|
|
|
DO icolumn = 1 TO NUM-ENTRIES( crow ):
|
|
ccell = ENTRY( icolumn, crow ).
|
|
|
|
coutput = coutput + "~n~t~t~t" + IF i_lhas_header AND irow = 1 THEN "<th>" ELSE "<td>".
|
|
coutput = coutput + REPLACE( REPLACE( REPLACE( ccell, "&", "&" ), "<", "<" ), ">", ">" ).
|
|
coutput = coutput + IF i_lhas_header AND irow = 1 THEN "</th>" ELSE "</td>".
|
|
|
|
END.
|
|
|
|
coutput = coutput + "~n~t~t</tr>".
|
|
|
|
END.
|
|
|
|
coutput = coutput + "~n~t</table>~n</html>".
|
|
|
|
RETURN coutput.
|
|
|
|
END FUNCTION. /* csvToHtml */
|
|
|
|
MESSAGE
|
|
csvToHtml(
|
|
TRUE,
|
|
"Character,Speech" + "~n" +
|
|
"The multitude,The messiah! Show us the messiah!" + "~n" +
|
|
"Brians mother,<angry>Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!</angry>" + "~n" +
|
|
"The multitude,Who are you?" + "~n" +
|
|
"Brians mother,I'm his mother; that's who!" + "~n" +
|
|
"The multitude,Behold his mother! Behold his mother!"
|
|
)
|
|
VIEW-AS ALERT-BOX.
|