On 18-May-11 01:59:23, Automation Department wrote: > Would like to create a very simple table macro. > eg., > > .de TABLE > .TS > box expand; > l s > l l. > \fI\\$1\fP > > .. > > This does not work though other similarly crafted macros do. > It 'starts' the macro at the macro definition. Do I need to > escape it? > > Also, if I just do: > > .de TABLE > box expand; > l s > l l. > \fI\\$1\fP > > .. > > Then call with > > .TS > .TABLE "Macro Junk" > column1 column2 > .TE > > I get: > tbl:final_rpt.roff:369: `.' not last character on line > tbl:final_rpt.roff:369: giving up on this table > > Just hoping to save some typing. > > Thanks! > - -- > Chad Roseburg
To deal first with your second example: The problem here is that the "." at the beginning of the second line will be interpreted as the "." that normally occurs at the end of the formatting lines. Note that this is different from the interpretation of "." when it occurs in a numerical context, such as when you are defining a minimum column width -- e.g. .TS box lw(1.5i) l. since that occurs inside "w()" where tbl is expecting to find a numerical expression. When the "." occurs at "top level" as in your ".TABLE ..." it will be taken at "face value", i.e. as the terminator for the formatting. Now for your first example. The problem here is that your macro ".TABLE" will be interpreted by troff, not by the preprocessor tbl. Note *pre*processor -- tbl does its work before troff sees the results. If troff expands a macro (such as your .TABLE) then it is too late -- the processing has moved on past tbl. Incidentally, you will get no result at all unless you include the ".TE" at the end of the macro definition, as in .de TABLE .TS box expand; l s l l. \fI\\$1\fP .TE .. .TABLE "Macro Junk" but even then it will not be the result you want. This is because tbl has already done its work, as explained above, as you can verify by deleting the line .TABLE "Macro Junk" (thus not calling the macro at all) -- tbl sees the .TS and .TE, ignores the fact that they are inside a macro definition (tbl does not recognise macros), and simply creates troff code for what it finds between them. Probably the simplest way to "save some typing" is to use the copy-&-paste functionality of your editor to copy down an existing instance of the table setup lines. Some editors will alow you to define a block of text and give it a name, so that when you invoke the name it will automatically insert the whole block. Hoping this helps, Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <ted.hard...@wlandres.net> Fax-to-email: +44 (0)870 094 0861 Date: 18-May-11 Time: 20:00:01 ------------------------------ XFMail ------------------------------