Angus Leeming wrote:

> Herbert Voß wrote:
>> Angus Leeming schrieb:
>>> Guys, the attached file works well enough, but it's rather inelegant. I
>>> have defined a macro, so:
>>> 
>>> \newcommand*{\verbatiminputOrWarn}[1]{%
>>>         \IfFileExists{#1}{\verbatiminput{#1}}{\warnNotFound{#1}}
>>> }
>>  > [...]
>> 
>> I would use the internal stuff.
> 
> [snip...]
> 
>> and now you can call verbatiminput as usual, with a star. too.
> 
> Many thanks, Herbert. Could you cast your eye over the attached file and
> see what improvements could be made. I'm trying to get the external inset
> to output this...

Doh! Here's the file.

-- 
Angus
\documentclass{article}
\usepackage{verbatim}

\makeatletter

%% Print a warning encased in an fbox.
\def\lyxstripprefix#1>{}
\newcommand*{\warnNotFound}[1]{%
        \def\lyxtempfilename{#1}%
        \fbox{Could not find%
                \ttfamily\expandafter\lyxstripprefix\meaning\lyxtempfilename!}
        \typeout{Could not find \lyxtempfilename!}\endgroup%
}

%% Input the file if it exists, using \input, else print a warning
\newcommand*{\inputOrWarn}[1]{%
        \InputIfFileExists{#1}{}{\warnNotFound{#1}}}

%% Redefine \verbatim to output a warning if the filcannot be found.
[EMAIL PROTECTED]
        \IfFileExists {#2}{%
                [EMAIL PROTECTED] #1\relax
                [EMAIL PROTECTED]@[EMAIL PROTECTED]@doendpe%
        }{%
                \warnNotFound{#1}
        }%
}

%% Input the file if it exists, using \include, else print a warning
\newcommand*{\includeOrWarn}[1]{%
        \IfFileExists{#1}{\include{#1}}{\warnNotFound{#1}}}

\makeatother
\begin{document}
Blah, blah, blah

\inputOrWarn{boxcount.tex}

Foo bar etc.

\verbatiminput{test_file.txt}

Foo bar below
\newpage

Foo bar 2 etc

\verbatiminput*{test_file.txt}

Foo bar 2 below
\newpage

Foo bar 2 etc

\verbatiminput*{/home/angus/test_file.txt}

Foo bar 2 below
\newpage

Foo bar 3

\includeOrWarn{./snapshot_t=40}

Foo bar 3 below.


\end{document}

Reply via email to