The Hard Way
The hard way is the obvious way:
on RenderTableAsXXX( tableAdr )
 local
 outText = ""
« Open HTML table
« Walk tableAdr^ and add an HTML table row for each item
« Close HTML table
 return( outText )
|
Why it's the hard way isn't so obvious, though. Once again, a wealth of sins is concealed by a single glib comment: Walk tableAdr^ and add an HTML table row for each item. In fact, this step involves not just adding <TR> and <TD> tags, but any necessary formatting of the entries. And either the script has to provide a way for you to specify the format externally (perhaps using custom directives) or you will have to modify or replace the script to change the formatting.
So, doing it the hard way, you end up with a script that looks like this:
on RenderTableAsXXX( tableAdr )
 local
 outText = ""
 idx
 on Add( s )
 outText = outText + s
 Add( "<table>\r" )
 for idx = 1 to sizeOf( tableAdr^ )
 Add( "<tr>" )
 Add( "<td><font face='sans-serif'><b>" + nameOf( tableAdr^[idx] ) \
 + "</b></font></td>\r" )
 Add( "<td>" + string( tableAdr^[idx] ) + "</td>\r" )
 Add( "</tr>\r" )
 Add( "</table>\r" )
 return( outText )
|
It ends up cluttered and confusing, and is a pain to maintain and modify.
Now let's look at the easy way to do it.