Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: I can't get fs to work from inside a do file


From   n j cox <[email protected]>
To   [email protected]
Subject   Re: st: I can't get fs to work from inside a do file
Date   Sun, 17 Feb 2008 16:49:14 +0000

Gabi Huiber sent in a question about my -fs- (downloadable from SSC) and Joseph Coveney and Michael Blasnik gave various good advice. I didn't
see in the thread following any details on what kind of values the global ${paper} might take on.

If that global included embedded spaces say "foo bar", then
after macro substitution the command line would read

fs prototype/foo bar/*.do

and Stata's standard command line processing would cause -fs- to see two arguments

prototype/foo

bar/*.do

and you might well find that no such files are reported to exist. As always the remedy for that is to bind the argument in double quotes, as
in

fs "prototype/${paper}/*.do"

and in any case that should do no harm. However, it does seem unlikely that this is biting, as you can get it to work in some cases and not others.

Presumably you have checked that your current working directory in the interactive session and that for the do file are the same.

Beyond that, my only suggestion is to remember that -fs- is just a wrapper. Trying the underlying Stata command might help identify whether you have found a bug or limitation in -fs- or a bug or limitation in the underlying command, in this case

local files : dir "prototype/${paper}" files "*.do"

Some time I ago I reported to StataCorp a bug in -: dir- which underlay what had been reported to me as a bug in -fs-. I don't know if it was ever fixed.

Nick
[email protected]

Gabi Huiber
===========

Nick Cox has this little command called fs, which reads the files in a
certain folder and remembers them in r(files). I tried to use it to
run a bunch of do-files from inside a root do-file, because the name
and number of these subsequent do-files can vary between the
sub-folders of interest. So here's what I did:


. ***************** CALL DO-FILES SPECIFIC TO EACH ${paper} HERE
.
. fs prototype/${paper}/*.do
> local dofiles=r(files)
>
> foreach k of local dofiles {
> do "prototype/${paper}/`k'"
> }
>
> clear
> di "goodbye"

As you can see, Stata breezes right through the lines after fs. It
also does not interpret fs: display r(files) shows nothing. However, I
can copy the fs line from the results window and paste it in the
command window, and it will execute just fine. Ditto for all the lines
below it.

*
* 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/




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