help for tfinsert(Roger Newson)

Insert text from an instream line sequence and/or an existing file into an open text file

tfinsert handle [ using filename ]
[ , terminator(string) maxlines(#) ]

Description

The tfinsert package inserts text from an instream dataset and/or an existing text file
into a text file open for text output and identified by a handle recognised by the file command.
This allows the user to insert text into a TeX, HTML or XML file
that is being built by a Stata do-file.

Options for tfinsert

terminator(string) specifies a terminator string,
used to terminate an instream sequence of lines of text following the rtfinsert command.
If terminator() is present,
then tfinsert will insert into the open document the following lines,
until a line containing only the terminator() string is encountered,
or until the number of lines is equal to the maxlines() option (see below).
If both a terminator() option and a using qualifier are present,
then tfinsert will first insert the instream sequence of lines,
and then insert the lines of text from the using file.
Note that the instream lines will be left- and right-trimmed
before being output to the open file.
This will not be a problem if the open output file is a TeX or HTML document.

maxlines(#) specifies a maximum number of lines of RTF code
to read from the instream sequence of lines of RTF code.
If maxlines() is absent,
then it is set to a default value of 1024.

Examples

The following example builds a HTML file mypage1.htm,
using a simple HTML head file myhead1.htm
and a simple HTML foot file myfoot1.htm,
and inserting the HTML body text from an instream sequence of lines in the do-file.
The file myhead1.htm is assumed to be as follows:

. <head>

. </head>

. <body>

And the file myfoot1.htm is assumed to be as follows:

. </body>

And the Stata code for building mypage1.htm is as follows:

. tempname myhandle1

. file open `myhandle1' using mypage1.htm, text write replace

. tfinsert `myhandle1' using myhead1.htm

. tfinsert `myhandle1', terminator(END_HTML)

. <p>

. Hello, world!!!!

. </p>

. END_HTML

. tfinsert `myhandle1' using myfoot1.htm

. file close `myhandle1'

Author

Roger Newson, National Heart and Lung Institute, Imperial College London, UK.

Email: r.newson@imperial.ac.uk

Also see

Manual: [P] file

Help: [P] file