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

RE: st: tempfile & scope


From   Nicholas Winter <[email protected]>
To   [email protected]
Subject   RE: st: tempfile & scope
Date   Thu, 25 Sep 2003 14:13:24 -0400

At 06:57 PM 9/25/2003 +0100, you wrote:
Danielle H. Ferry

> It has
> become glaringly obvious that I don't understand the
> purpose of -tempname-
> here. Can someone please explain?

Well, in fact, I guess it's dispensable.

You need a postname; it's just a convention
to use a temporary name, as that way Stata
_guarantees_ that it will not get confused
with any other file operations it may be
doing concurrently.

Without a tempname you lose that guarantee,
but problems are perhaps unlikely in
most situations. You would have to work
quite hard at it e.g. using the same
postname for different operations in different
programs in the same session could produce
an interesting mess.

[P] Post recommends using a temporary name for the postname; this ensures both no name conflicts, and that things are cleaned up if the program terminates in an error (including, if the user presses -Break-).

If you hard-code a postname, and your program crashes, then when you re-run it you will get an error when the program issues the -postfile- command, using the (still-in-use) handle.

If you hard-code the filename, then any partial results will be in place if the program ends in error...which you may or may not want.

-Nick Winter



Nick
[email protected]
*
*   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/
--------------------------------------------------------
Nicholas Winter 308 White Hall
Assistant Professor t:607.255.8819
Department of Government f:607.255.4530
Cornell University [email protected]
Ithaca, NY 14853-7901 falcon.arts.cornell.edu/nw53
*
* 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