Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: [Stata 9] Convincing Stata to let me quit the program withoutconfirmation


From   James Muller <[email protected]>
To   [email protected]
Subject   Re: st: [Stata 9] Convincing Stata to let me quit the program withoutconfirmation
Date   Sat, 27 Aug 2005 23:08:35 +1000

If you're just wanting to run, check, then conveniently leave Stata by Alt-F4, then keep in mind the query about closing should focus itself, so (I think) you type Alt-F4 and then Enter.

The OS thing is just if you want to check that Stata is running. A method under Unix/Linux/etc could be the little script

stcmd=stata
x=`ps -A | grep $stcmd`
if [ "$x" = "" ]; then
$stcmd;
fi

First line defines a string that describes the stata executable; second line tests whether a Stata process is running; the rest run Stata if there is no process.

The nice thing about Unix and derived operating systems is the truly fantastic set of commands to perform useful operations. You can pretty much do anything (though sometimes slowly) using the on-hand commands available in a standard distribution of unix/linux/etc. Use it and you will see how amazingly flexible the operating system is - windows simply does not, and probably never will, compare in this sense. Major, major difference.

Whether or not you're able to pass input to a currently running Stata process is a whole different matter. In theory it is possible, though I'm not quite sure how. See, Stata under Unix will receive input from a thing called the X11 server, which is kind of like the frontend of Windows except less restrictive. It works something like this (may be a bit off with some stuff here): you send input to the keyboard, which is being passed to the kernel (the Linux brain), and then that is being forwarded to X11. X11 then checks which window/whatever has focus and passes the input there. So you have the Stata command input window in focus, type, and input appears. There should be nothing stopping someone from identifying the Stata process, figuring out what should be the command input window, and passing stuff directly to it in other ways. Who knows, maybe there is even a simpler way to do this.

Actually, here's an idea: Create a do file that does just one thing: search for a file in a particular location and then sleep for a second; if the file exists then 'do' it, but delete the do file afterwards; next begin process again. This is essentailly a "daemon", something that runs in the background and does 'stuff' intermittently (these are what webservers are). At the user end, every time you update your file you would copy it to this search location and it would automatically run.

Again, 'make' would be a nice combination with this 'daemon mode' for Stata.

Lots of options. Anyway, I hope some of this is useful or at least interesting.

Cheers

James








Seb Buechte wrote:


James,

thanks for your kind reply. But, the way I am using dofiles is that I
want to run the dofile, check the output, maybe try out a few commands
to check whether everything worked out the way I wanted it to be, and
then quit the program by a single click or by pressing the famous
ALT-F4 shortcut.

To my last point. How would you do it under UNIX or anything derived
from that OS? Do you identity whether a stata instance is running and
than force that process to take the dofile as a new argument? I have
some problems to imagine how one would achieve such behaviour. Anyway,
I would be delighted to get to know more about this.

Kind regards,
sebastian


On 8/27/05, James Muller <[email protected]> wrote:


Have you read the help on exit?

. help exit

May be missing something, but don't you just want to end te do file with
the line

. exit, clear STATA

If you want this to be optional you could begin your do file with

. args force_exit

and finish it with

. if ("`force_exit'" != "") exit, clear STATA

Then call your do file with the command

> stata do mydofile.do force_exit

or whatever is equivalent on Windows.


From your last point (and the way you're using do files) it sounds like
you'd enjoy unix/linux/etc. There is probably a simple way to check for
processes using the Windows OS, but I'm not a Windows person so maybe not.

James




Seb Buechte wrote:



Hello everybody!

I raised this issue once before and still, I would really appreciate
the possibility to "convince" Stata to let me quit the program without
confirmation that "I really want to do this, eventhough my data has
changed..."

I am using Stata with an external editor to write (I dare to say "to
program") my dofiles. I have managed to run the dofile from inside
this editor by calling the Stata environment. Each time I invoke Stata
to run my dofile, Stata will create a new instance. That is fine for
me, but what bothers me is that I cannot turn off that
confirmation-message-box which will appear each time I want to close
that Stata instance that holds changed data. I wonder wether there is
a hidden feature which could be activated to keep Stata of requiring
that confirmation. If no such thing should exist, why not adding it?
The default could still be the "paranoid"-mode to prevent users of
loosing their created data. But for all those who feel like they know
what they are doing it would be great to be able to turn such mode off
- at least it would be for me...

Another idea that just came across my mind is that it would be also
very nice to have a command line option for the wsestata-binary that
would check wether Stata is already running and if so to have the
dofile executed within the last Stata instance started. I know this
goes out to Statacorp's programmers. Still, why not asking for it?

Thank you for considering this :)

Sebastian





*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index