Traversing through a table
Andre Radke
lists at spicynoodles.net
Fri Oct 18 16:47:31 PDT 2002
At 16:14 -0700 18.Oct 2002, Jeff Shepherd wrote:
>Let's say I've got a table called scratchpad.fruit and within the
>fruit table I've got names and values that look like this
>
>Name Value
>apple red, crunchy, round
>grape green, soft, oval
>
>I want to generate HTML code from the table that looks like this
>
><TABLE>
><TR><TD>apple <TD>red <TD>crunchy <TD>round
><TR><TD>grape <TD>green <TD>soft <TD>oval
></TABLE>
>
>I can do the nitty-gritty about extracting values from a
>comma-delimited string and returning the generated HTML text. What
>I would like some advice on is how to traverse the table.
The for..in loop construct can be used to traverse a table, e.g.:
local (s = "");
local (adritem);
local (adrdata = @scratchpad.fruit);
for adritem in adrdata {
s = s + "<TR><TD>" + nameOf (adritem^) + " ";
s = s + "<TD>" + string.replaceAll (adritem^, ",", "<TD>") + cr;}
s = "<TABLE>" + cr + s + "</TABLE>";
HTH,
-Andre
More information about the Frontier-Users
mailing list