Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: capture confirm file always returns 7
From
"Walsh, Lee" <[email protected]>
To
"[email protected]" <[email protected]>
Subject
st: capture confirm file always returns 7
Date
Fri, 20 Sep 2013 15:17:54 +0000
Hello Statalist,
I am having trouble using -capture confirm file-, it's performance does not seem to match documentation, I must have missed something.
Here is a snippet:
mata: st_local("filePath",sprintf("NewData/S%g/surveyResults_W1.txt",`subjN'))
mata: printf("\tFile: %s\n",st_local("filePath"))
capture confirm file `filepath'
display _rc
if _rc==7 {
So the idea is that the if statement should only execute if the file specified by `filepath' exists. The documentation on -confirm file- suggests that and rc of 7 should be returned if the file is found, 601 is returned if the file is not found and 603 if it is there but not openable. This is consistent with what happens if I do the command individually in the stata terminal.
However, if I run the commands from a .ado, regardless of whether the file exists the -if- statement in my code is always run. The -display _rc- line shows me that _rc always ==7 no matter the value of `'filepath' or the existence of the relevant file.
What am I missing? Despite the examples showing that I should test _rc, should I be testing something else?
Thanks for any help
Lee.
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/