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

st: Dialog box problem with -clear- command


From   "Steichen, Thomas" <[email protected]>
To   <[email protected]>
Subject   st: Dialog box problem with -clear- command
Date   Wed, 26 Mar 2003 12:18:53 -0500

I have received a follow-up from StataCorp (James Hassell, in
particular) who has kindly clarified the issue with the -clear-
command and dialog boxes.  He writes (in part):
 
> Regarding the -clear- command; As noted -clear- invokes 
> -discard- which causes the dialogs to be closed and their 
> contents cleared.
> 
> The following is an excerpt from -help discard-.
> 
> "clears all class definitions and instances (see help classutil); 
> and closes all dialogs and clears their remembered contents 
> (see help dialogs)."
> 
> The reason -preserve- can't save the contents of dialogs, is 
> because, -preserve- only saves the data and not the contents
> of the class system. Therefore, if -clear- is invoked after
> a -preserve-, all class instances are cleared and not recoverable.

This makes it clear that that -clear- is not a command you want
to use in conjunction with a program that uses a dialog box.

Clearly, the right programming approach is to use the most minimal
"clearing" command that accomplishes the needs of a particular
program.  James wrote elsewhere:

> The -clear- command not only clears the dataset from memory,
> it also clears many other things too.
> 
>     Clear is equivalent to typing:
> 
> 	. version 8
> 	. drop _all
> 	. label drop _all        (see help label)
> 	. scalar drop _all       (see help scalar)
> 	. matrix drop _all       (see help matrix)
> 	. cluster drop _all      (see help cluster)
> 	. eq drop _all
> 	. constraint drop _all   (see help constraint)
> 	. postutil clear         (see help postutil)
> 	. _return drop _all      (see help _return)
> 	. discard                (see help discard)

In the particular instance I encountered, a third-party program
that I called within my own program (for which I was writing
the dialog box), used -clear- to allow -tabi- to automatically
retain its dataset as the current dataset.  Using -drop _all-
instead would have accomplished this same task without wiping out 
the whole active environment.  Alternatively, the -replace- option 
of -tabi- would have done the same thing.

Looking at the list of what -clear- does, it seems clear to
me that one should not programmatically use that command unless
no other approach suffices, especially if one intends for the 
environment to be restored with a subsequent -restore- command.

My thanks to James Hassell, StataCorp, for making this clear.

Tom Steichen


-----------------------------------------
CONFIDENTIALITY NOTE:  This e-mail message, including any
attachment(s), contains information that may be confidential,
protected by the attorney-client or other legal privileges, and/or
proprietary non-public information.  If you are not an intended
recipient of this message or an authorized assistant to an intended
recipient, please notify the sender by replying to this message and
then delete it from your system.  Use, dissemination, distribution,
or reproduction of this message and/or any of its attachments (if
any) by unintended recipients is not authorized and may be unlawful.


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