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

RE: st: Crash Command


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Crash Command
Date   Tue, 27 Apr 2004 15:13:14 +0100

To go back to the original question, 
one solution I've not seen mentioned
is to ask the programmer. It is 
possible of course that the programmer
has died or is otherwise inaccessible; 
also possible that the name of the programmer
isn't clear from the documentation
or the program itself, which if true 
I personally would take to be a bad sign. 

That said, Richard asked some questions, 
which I'll answer piecemeal. 

Nick 
n.j.cox@durham.ac.uk 

Richard Williams
> 
> Could it be that Crash is (or was) hiding inside profile.do 
> or some other 
> do or ado file?  I added these lines to my profile.do:
> 
> program define hello
>     display "Hello, Rich"
> end
> program define mylist
>     list, sep(8)
> end
> 
> and both the -hello- and -mylist- commands then work from within 
> Stata.  However, neither shows up when I use the -which- 
> command.  So, 
> maybe you should look at profile.do and/or do a search of all 
> your do and 
> ado files to see if -crash- is defined within them.
> 
> Incidentally, -hello- and -mylist- continue to work even after I type 
> -clear- or -discard-.  I thought they would go away.  So, it 
> seems like any 
> little shorthand commands you want could be defined in profile.do.

Correct. But what advantage would there be in doing that? You 
just end with programs sitting there taking up possibly valuable space. 
Also, you run the risk that you or somebody else following
this advice has a program in memory and finds it difficult 
to find out where it was defined, precisely the point under
discussion. 

To find _what_ it is, 

. program li hello 

will do the trick if it's loaded. 

As to why this happens, note the nuance in the help. "-discard-
drops all automatically loaded programs (see [U] 20.2 What is 
an ado-file?)." These are those defined by ado files, 
which are by definition visible somewhere along your -adopath-. 
They are loaded in memory when you need them and (unobtrusively) 
unloaded when it's thought you don't need them. That category 
excludes programs defined by do files, and those defined 
interactively, which aren't automatically loaded. 

> I've seen a lot of ado files that define programs within 
> their programs -- 
> do these routines continue to hang around after the ado file 
> has finished, 
> or what?  Could they be called separately, e.g. if -myado.do- 
> defined a 2nd 
> program, -myotherado-, could I then make a direct reference 
> to -myotherado- 
> from within Stata?

Programs defined within programs, or 
subroutines (to adopt the old Fortran term), hang around, 
qua subroutines, until flushed because their parent programs 
are not being used. Type -program dir- occasionally 
to see this. 

They can't be invoked as such. Among other points, 
the rationale of subroutines is to act under the control 
of another program. I guess that the developers took a decision 
not to allow them to be visible as if they were programs in their own 
right on the grounds that it would usually be pointless, 
confusing or both. Any subroutine useful in its own 
right can also be defined as a separate program, in 
any case. There are languages in which every program 
has similar standing, but that's a point for designers
to think through for themselves. It is not true of 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index