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: exit from interactive Mata, gracefully?


From   Stas Kolenikov <[email protected]>
To   [email protected]
Subject   st: Re: exit from interactive Mata, gracefully?
Date   Wed, 25 May 2011 23:29:27 -0500

On Wed, May 25, 2011 at 10:35 PM, Joseph Coveney <[email protected]> wrote:
> what is the appropriate way of handling the following situation? I
> have a do-file that uses a mix of Stata and Mata. At some point, due
> to some unsurmountable (numeric) difficulties (I actually have a
> rather complicated optimization problem), Mata has to break, and the
> do-file needs to be exited.  . . .
>
> [do-file omitted]
>
> So -stata("exit")- does not work there.  . . .
>
> --------------------------------------------------------------------------------
>
> It does for me.  See do-file and output below.
>
> Joseph Coveney

May be I did not explain it well. I added just one line:

== do-file ==
*! tryit.do by Joseph Coveney

version 11.2

set more off

local decision `0'

mata:

if (st_local("decision") == "bail") {
      printf("Bailing out!\n")
      stata("exit = 0")
}
else {
      st_local("decision", "Flying home!")
}
printf("Still there...\n")

end

display in smcl as text "`decision'"
display in smcl as text "do-file terminated normally"

exit
== end of do-file ==

You are "still there" no matter what the `decision' is. And I wanted
to exit before that once and for all.

--
Stas Kolenikov, also found at http://stas.kolenikov.name
Small print: I use this email account for mailing lists only.

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