bug-groff
[Top][All Lists]
Advanced

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

RE: Question


From: Ted Harding
Subject: RE: Question
Date: Wed, 11 Jul 2001 10:29:46 +0100 (BST)

On 10-Jul-01 Charlie Sorsby wrote:
> Please forgive this slightly off-topic post; I haven't been able to
> find *any* other [gnt]roff news group with the slightest activity.
> This one is slow, here, but at least there have been a few posts.
> 
> If there's another news group that I should post this to, I'll
> sincerely appreciate a pointer to it.
> 
> Here's my question:  Is it possible for a [gnt]roof source file to
> access it's own file name?
> 
> Here's what I'd like to do:  The version of the document will be
> part of the filename (e.g. document.00.e, document.01.e, etc).
> When I ?roff the file, I'd like ?roff to put the filename in the
> footer very much as it is capable of putting the page number there
> by using "%" in one of the footer spaces.  I'm using the .me
> macros.

Use the "number" register .F which "contains the name of the current
input file, as set by command line argument [i.e. the filename if
given in the command line], .so, .nx or .lf". [Troff User's Manual,
1992, section 20]

E.g. run "groff -Tascii temp" on the file "temp" containing

  The name of this file is \n[.F]

However, if you do any "external" preprocessing (say with a 'sed' or
'awk' filter) and then pipe the result to groff, e.g. like

  cat temp | groff -Tascii

the result you get will look like:

  The name of this file is <standard input>

The only way round this would be to use the command-line option "-d"
within a script, to define a user-defined variable to have the value
of the filename which would be set as a shell variable, e.g. like

  cat $1 | groff -Tascii -duserfile=$1

where the script is invoked by a command like

  mygroff temp

Then, in the troff source file itself, you can get at the file name
by "\*[userfile]", just like using "\n[.F]".

Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 167 1972
Date: 11-Jul-01                                       Time: 10:29:46
------------------------------ XFMail ------------------------------



reply via email to

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