Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: limitation of -filefilter-

From   [email protected] (Kevin Turner)
To   [email protected]
Subject   st: Re: limitation of -filefilter-
Date   Tue, 23 Nov 2004 08:53:31 -0600

Phil Schumm <[email protected]> writes:
>-filefilter- does appear however to have some limitations regarding 
>how the file(s) are specified.  First, it doesn't appear that you can 
>use paths in the file specifications.  For example:
>. filefilter /Users/pschumm/foo.txt /Users/pschumm/foobar.txt, f("a") t("b")
>varlist not allowed

This is a bug; it is incorrectly parsing on non-space characters. If you use
double quotes to enclose the paths it will work, but the original problem will
be fixed in the next executable update. If any path contains spaces, it will
always need to be double quoted, for -filefilter- or any other Stata command.

>Second, if I've got a "$" embedded in a file name, I can't seem to 
>specify the file.  For example:
>. filefilter foo\$bar.txt foo\$bar2.txt, f("a") t("b")
>varlist not allowed
>where the "\" is (presumably) needed to escape the "$", thus 
>preventing macro expansion.

Yes, the slash does prevent macro expansion. The reason that a single backslash
doesn't work here lies in the fact that there is already a backslash preceding
the file name. When the first pair of backslashes is encountered, they collapse
down to a single backslash (there is a backslash escaping a backslash). The
next character to be parsed is the dollar sign, which now has no preceding
backslash since the previous two were already parsed. The necessary solution
requires three backslashes for the Stata parser to correctly interpret the
path. Thus, a correct path would look like:

. filefilter "foo\\\$bar.txt" "foo\\\$bar2.txt", f("a") t("b")

This issue involving escape characters and macro expansion is, unfortunately, 
one that you could encounter with any Stata command, not just -filefilter-.

Hope this helps.

[email protected]
*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index