groff
[Top][All Lists]
Advanced

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

Re: [Groff] conditional for file existence?


From: Gaius Mulley
Subject: Re: [Groff] conditional for file existence?
Date: 16 Jul 2003 23:12:16 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Werner LEMBERG <address@hidden> writes:

> > Is there a way to check if a filename names an existent file?
> 
> No.  You are the first one who asks this question here.
> 
> Perhaps we should do the same route as TeX, namely adding .openr,
> .read, and a new operator to .if:
> 
>   .openr <stream> <file>
>   .read <stream> <string variable>
>   .if f <stream>
> 
> `openr' opens a file for reading.  It does *not* produce an error.
> [Use the `close' request to undefine the stream handle.]
> 
> `read' gets a line (in text mode; stripping the final newline) from a
> stream and puts it into a string variable.
> 
> The new conditional operator `f' returns zero if either the stream is
> not open or we are at EOF.
> 
> Both `read' and `if f' return an error if the specified stream
> doesn't exist.
> 
> A file test for file foo.bar would then look like this:
> 
>   .open FILE foo.bar
>   .if f FILE \{\
>   .  close FILE
>   .  so foo.bar
>   .\}
> 
> For a zero-length file, `if f' will be true before the first call to
> `read' but not afterwards.
> 
> Any volunteer to implement?
> 

I like this concept - it sounds useful and neat. However I'm still
fighting tags and environments..

Gaius

reply via email to

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