Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: c(mode) with console Stata on OS X


From   "William Gould, StataCorp LP" <wgould@stata.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: c(mode) with console Stata on OS X
Date   Mon, 02 May 2011 13:29:12 -0500

Concerning Mac OS X, Phil Schumm <pschumm@uchicago.edu> wrote, 

> Today I fired up an old tool chain that threw an error because c(mode)  
> doesn't seem to exist under console Stata on OS X (and therefore code  
> that uses this to detect whether Stata is running in batch mode didn't  
> work).  

It appears that Phil has found a bug, and not just on the Mac.  I just
observed exactly what Phil reports on a Linux box, and it appears to 
me that the bug has been there for years.

Stata originally had $S_MODE.  The global macro contained nothing (did
not exist), or contained "batch" if Stata was running in batch mode.
Originally, only console versions of Stata could not run in batch mode.
Over the years, GUI versions of Stata learned how to run in batch mode
and, separately, we introduced c().

The current state of affairs is

     1.  All Stata's have $S_MODE that will contain "batch" if running in 
         batch mode.

     2.  GUI versions have c(mode), too.

     3.  Documentation was recast as if c(mode) replaced $S_MODE.

Our intent (I'm guessing based on our records) was that all Stata's
support c(mode), but we made a mistake and never noticed that they
didn't.  We here at StataCorp seem to be using $S_MODE, mainly because
we remember better than anyone else older syntax, and we just never
adjusted.  Meanwhile, no one outside of StataCorp found the bug until now.

So we will fix it, but we are not going to rush.  In the meantime, 
I recommend using $S_MODE.  It works today, and it will work tomorrow.
To determine if you are running in batch mode, code

	if ("$S_MODE"=="batch") ....

to determine if you not running batch, code

	if ("$S_MODE"=="") ....

That works on all platforms and will continue to work (and be undocumented).

-- Bill 
wgould@stata.com
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index