groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: pic doesn't center when i use a macro


From: Douglas McIlroy
Subject: Re: pic doesn't center when i use a macro
Date: Mon, 1 Nov 2021 21:31:54 -0400

Remember that macros work by substitution. So each line of label_for
becomes a separate line in the macro-expanded program. A label alone
on a line gets plotted at the current point, which in this case is
last box.e.  (The macro definition begins with an empty line. If it
didn't, then the case-0 line would have been pasted on the end of
the dashed-box line and manifested as a syntax error.)

BTW, what are the empty strings ("") for? Formally, they make a
three-line label, too high for the dashed box.

(The code layout below differs slightly from the original. I inserted
the backslash-newline to keep gmail from breaking the line at an
awkward place.)

Doug

> .PS
>
> define label_for {
>     if $1 == 0 then { "Ent?te Ethernet"      } else {
>     if $1 == 1 then { "Ent?te IP"            } else {
>     if $1 == 2 then { "Ent?te TCP"           } else {
>     if $1 == 3 then { "Donnees applicatives" } else {
>     } } } }
> }
>
> w = 3 ; h = 2; margin = .2 ; tr = 2 * margin
> for layer = 0 to 3 do {
>     s = layer * margin
>     box width w height h with .sw at (s,s)
>     box width w height margin with .nw at last box .nw dashed \
>        "" label_for(layer) ""
>     w = w - tr
>     h = h - tr
> }
> .PE



reply via email to

[Prev in Thread] Current Thread [Next in Thread]