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]

st: Re: Make ado file end processing of calling do file


From   "Joseph Coveney" <[email protected]>
To   <[email protected]>
Subject   st: Re: Make ado file end processing of calling do file
Date   Tue, 24 May 2011 09:55:11 +0900

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?

--------------------------------------------------------------------------------

Well, an ungraceful-but-effective way is to put

if `certain_conditions' exit = 1 // choose any informative nonzero integer here

in your called ado-file.  This will stop everything and return control to
Stata's command prompt.

But it might be better to have a little more coupling between your calling and
called ado-files than this.

Joseph Coveney

=== begin illustration.do ===

version 11.2

program define caller
	version 11.2
	syntax

	called
	display in smcl as text "caller terminated normally"
end

program define called
	version 11.2
	syntax

	if 1 == 1 exit = 1
end

caller

exit

=== end illustration.do ===


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


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