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 = "~n~t
".
DO irow = 1 TO NUM-ENTRIES( i_cinput, "~n":U ):
coutput = coutput + "~n~t~t".
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 "| " ELSE " | ".
coutput = coutput + REPLACE( REPLACE( REPLACE( ccell, "&", "&" ), "<", "<" ), ">", ">" ).
coutput = coutput + IF i_lhas_header AND irow = 1 THEN "" ELSE " | ".
END.
coutput = coutput + "~n~t~t
".
END.
coutput = coutput + "~n~t
~n".
RETURN coutput.
END FUNCTION. /* csvToHtml */
MESSAGE
csvToHtml(
TRUE,
"Character,Speech" + "~n" +
"The multitude,The messiah! Show us the messiah!" + "~n" +
"Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!" + "~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.