groff
[Top][All Lists]
Advanced

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

Re: macro returning a value?


From: Ulrich Lauther
Subject: Re: macro returning a value?
Date: Sun, 14 Nov 2021 12:33:38 +0100

On Sat, Nov 13, 2021 at 12:19:09PM -0500, Peter Schaffter wrote:
> On Sat, Nov 13, 2021, Ulrich Lauther wrote:
> > Is there a trick to make a macro or string return a value?
> <snip>
> > The only solution I found looks like this:
> > 
> >         .de Pos END
> >         .nr foo (\\n[.d]u-\\[.v]u)*254+1)/72000
> >         \\n[foo] mm/10
> >         .END
> > 
> >         .fi
> >         position: \n[.d] units,
> >         .Pos
> 
> .nr foo has an error -- s/b \\n[.v] -- and the u scaling indicators
> are superfluous.  Fixed, the macro could be written
> 
>   .de Pos
>   \R'foo (\\n[.d]-\\n[.v]*254+1)/72000'\\n[foo]mm/10
>   ..
> 
> which allows you to enter
> 
>   position: \n[.d] units, \*[Pos].
> 

Wow! Works nicely.

But why is "R" escaped only once? \\R works too.
And I had to add a line ".sp -1v" at the end of the  macro; otherwise I get a
blank line after position: ...

        ulrich



reply via email to

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