Nick Cox wrote
> Ulrich Kohler
> > Is there a way to wrote a single opening quote to a file
> > with -file wrote-?
> >
> > In a program I have the command
> >
> > file write texfile `"`line'"'
> >
> > which wrotes the contents of the local macro `line' to the
> > file handle
> > "texfile". The command works well except for lines which
> > contains either a
> > local macro name (like `a') , or a single opening quote. In
> > the first case
> > Stata expands the local macro name to the contents of the
> > local macro. But I
> > want to have the local macro name (`a') in my file handle.
> > In the second case
> > I got an error message because Stata thinks that there
> > should be a valid
> > local macro name, which is not there.
> use _char(96)
This don't works for me. I got the macro `line' from -file read-. The file I
read may contain lines with single quotes and/or macro names. To wrote this
line (after some selections and/or replacements) to another file I use file
write. To use the _char(96)-solution I need to substitute single opening
quotes with something like:
local line: subinstr local line `"`"' `"_char(96)"'
which does not work.
Here is a (very) simple example of the problem. Consider the
following sequence:
file open texfile using saving.tex, replace write text
file open dofile using using.do, read text
file read dofile line
while r(eof)==0 {
file write texfile _n `"`line'"'
file read dofile line
}
file close dofile
file close texfile
This should "copy" the file using.do to the file "saving.tex" line by line.
It works---but not for lines with local macros...
--
[email protected]
http://www.sowi.uni-mannheim.de/lesas
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/