Frontier Tutorials / Writing Table Renderers / The Hard Way

The Hard Way

The hard way is the obvious way:

on RenderTableAsXXX( tableAdr )
space picturelocal
space pictureoutText = ""
space picture« Open HTML table
space picture« Walk tableAdr^ and add an HTML table row for each item
space picture« Close HTML table
space picturereturn( 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 )
space picturelocal
space pictureoutText = ""
space pictureidx
space pictureon Add( s )
space pictureoutText = outText + s
space pictureAdd( "<table>\r" )
space picturefor idx = 1 to sizeOf( tableAdr^ )
space pictureAdd( "<tr>" )
space pictureAdd( "<td><font face='sans-serif'><b>" + nameOf( tableAdr^[idx] ) \
space picture+ "</b></font></td>\r" )
space pictureAdd( "<td>" + string( tableAdr^[idx] ) + "</td>\r" )
space pictureAdd( "</tr>\r" )
space pictureAdd( "</table>\r" )
space picturereturn( 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.

Tutorial Contents
Writing Table Renderers
What Is A Table Renderer
Anatomy of a Table Renderer
The Hard Way
The Easy Way
The Easiest Way
About the Author