[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Groff] multi-line macro arguments
From: |
Ted Harding |
Subject: |
Re: [Groff] multi-line macro arguments |
Date: |
Wed, 27 Apr 2016 21:41:25 +0100 (BST) |
On 27-Apr-2016 18:24:41 Carsten Kunze wrote:
> Hi,
>
> ?ukasz Stelmach <address@hidden> 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!
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
.\}
..
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 that the separate lines in the input are read as
a single line (the end-of-line "\" suppresses interpretation
of the end-of-line). So:
.envaddr \
"Mr Obskewer" \
"999 Dead End" \
"Nowhere" \
"Caddo, OKLAHOMA" \
"USA"
Hoping this helps. And, by the way, lines without spaces (e.g."USA")
do not need to be enclosed in double quotes, so it could be called as:
.envaddr \
"Mr Obskewer" \
"999 Dead End" \
Nowhere \
"Caddo, OKLAHOMA" \
USA
Also, by the way, Nowhere realy exists in Caddo County, Oklahoma.
And there used to be a Nowhere in Norfolk, England, but it got
swallowed up into the nearby parish of Acle, about half-way
between Norwich and Great Yarmouth; so Nowhere is now nowhere.
See:
https://en.wikipedia.org/wiki/Nowhere,_Norfolk
https://en.wikipedia.org/wiki/Nowhere,_Oklahoma
Best wishes to all,
Ted.
-------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Date: 27-Apr-2016 Time: 21:41:17
This message was sent by XFMail
-------------------------------------------------