(Ted Harding) <ted.hard...@wlandres.net> writes: > On 27-Apr-2016 18:24:41 Carsten Kunze wrote: >> Łukasz Stelmach <steel...@post.pl> wrote: >> >>> I am developing a macro to print envelopes. Is it possible to pass a >>> multi-line string (not necessarily defined with .ds) as a parameter >>> for a macro? >> >> what exactly would you like to do? Can you please give an example? >> >> --Carsten > > There is a good point to Carsten's question, since things like > laying out addresses on envelopes can depend on a lot of detail!
I'd like to have as simple API as possible. Something like Steffen Nurpmeso's. I need groff only to typeset two diversions and place them properly (I've already got the placement part quite right) according to the paper size defined in the command line (-dpaper=c5l -P-pc5 -P-l). The content of the diversions is going to be assembled either "manually" (say, I've got a single envelope to print) or by a properly crafted script that reads a database. > However, you may find the following useful (no doubt with > some extra details to suit your formatting requirements). > The basic idea is not to give a "multi-line string" as a single > paramater, but to give the separate lines as separate arguments. > > This basic macro is called "envaddr" and is defined as follows: > > .de envaddr > \f[HB]\s[15]\\$1\s0\fP > .shift > .br > .while \\n[.$]>0 \{ ^^^^^^^^^^^^^^^^^^^^ > \f[HB]\s[12]\\$1\s0\fP > .br > .shift ^^^^^^^^^^^ These are the bits I haven't known that somehow prevented me from thinking about multiple (and variable number of) parameters. > .\} > .. > > You can then obtain the formatted output for an address, e.g.: > > .envaddr "Mr Obskewer" "999 Dead End" "Nowhere" "Caddo, OKLAHOMA" "USA" > > But you can equivalently input the components of the address on > separate lines, if you terminate each line (except the last) > with "\" [...] > So: > > .envaddr \ > "Mr Obskewer" \ > "999 Dead End" \ > "Nowhere" \ > "Caddo, OKLAHOMA" \ > "USA" Or maybe yours looks even better. > Hoping this helps. It sure does. Thanks a lot. -- Było mi bardzo miło. --- Rurku. --- ... >Łukasz< --- To dobrze, że mnie słuchasz.
pgp3KcFy1PzyP.pgp
Description: PGP signature