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: Make ado file end processing of calling do file
From
Paul Burkander <[email protected]>
To
[email protected]
Subject
Re: st: Make ado file end processing of calling do file
Date
Mon, 23 May 2011 21:13:17 -0400
Thanks for the quick responses.
Even if there is an alternative, the solution of exiting with an exit
code is perfect for me. I need everything to come to a screeching
halt, with out any possibility of the user accidentally bypassing the
error; this'll do it.
Paul
On Mon, May 23, 2011 at 9:08 PM, Phil Schumm <[email protected]> wrote:
> On May 23, 2011, at 7:02 PM, Paul Burkander wrote:
>>
>> I'm new to writing ado files, and I'm having some trouble. I'd really
>> like my ado file to stop the processing of the calling do file if certain
>> conditions are met. I guess "exit" just returns control to the calling
>> program.
>>
>> Is there any way to make the calling program completely top based on a
>> condition encountered in the ado file?
>
>
> There are several ways to do what you want. For example, you could have
> your program exit with a specific return code, and then trap this in your
> do-file:
>
>
> program define foo
> <program code ...>
> if <condition> {
> exit = <return code>
> }
> end
>
>
> cap foo
> if _rc == <return code> {
> exit
> }
>
>
> Alternatively, you could have your program set a global macro, and then
> check for specific values of this macro in your do-file following your call
> to the program. Though there are other ways, these are perhaps the best
> two.
>
> The real question, however, is what are you trying to do? I'm guessing that
> there might be an alternative (and perhaps better) way to approach the
> problem...
>
>
> -- Phil
>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/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/statalist/faq
* http://www.ats.ucla.edu/stat/stata/