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

RE: st: tempfile & scope

From   Nicholas Winter <>
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

*   For searches and help try:
Nicholas Winter 308 White Hall
Assistant Professor t:607.255.8819
Department of Government f:607.255.4530
Cornell University
Ithaca, NY 14853-7901
* For searches and help try:

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