Bookmark and Share

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]

Re: st: capture confirm file always returns 7


From   "Walsh, Lee" <[email protected]>
To   "<[email protected]>" <[email protected]>
Subject   Re: st: capture confirm file always returns 7
Date   Fri, 20 Sep 2013 15:52:07 +0000

Well, it was a typo that  I realised too late.  filePath v. filepath.

Sorry for time wasting on that one, however things do not yet work as expected.

 _rc does not equal seven if the file it found, it is in that case _rc==0.  I have found some example code that is consistent with this, but the documentation on -confirm file- suggests otherwise.  It almost seems that _rc==0 unless there is a 'true' error (i.e. if it's not 60x, it's 0).

However, if I run the commands in the terminal _rc==7 when file found, but in a .ado _rc==0 when the file is found.

Does anyone know why this is the case?

Thanks
Lee.


On 20/09/2013, at 4:17 PM, Walsh, Lee wrote:

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



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


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index