Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Capturing the directory of a .do file


From   "Matthew Clifford" <[email protected]>
To   <[email protected]>
Subject   st: Capturing the directory of a .do file
Date   Thu, 6 Sep 2007 10:37:19 -0400

I am trying to find a way to have Stata automatically recognize the path
from which a .do file is run. 

Each of my projects has its own folder, with various subfolders for
different elements. I tend to define all of the paths in one path.do
file and run this first. For example:

global ROOT "C:\My Documents\Project1\"
global DOFILES "${ROOT}do files\"
global INPUT "${ROOT}input data\"
global OUTPUT "${ROOT}output data\"
global OUTSHEETS "${ROOT}outsheets\"
global LOGFILES "${ROOT}log files\"

When I give my code and data (in their respective folders) to other
people I include the instructions that ROOT must be changed to wherever
they create the project folder and that this path file must be run
before the others. This is difficult for some people. I would like to
find a way to automatically recognize the directory from which a .do
file is run, that way I can back out of the DOFILES folder and define
ROOT without needing to know anything about the computer from which this
is being run, other than that it is Windows. 

One possibility is to somehow capture the display from the doing of a
.do file, which shows up when one double clicks the file to execute it. 

. do " C:\My Documents\Project1\do files\path.do"

But I don't know how to do that and I can't be sure that my users won't
do the file from within the Stata text editor, in which case the display
will be 

. do "C:\DOCUME~1\ME~1\LOCALS~1\Temp\STD01000000.tmp"

Which is not the actual location of anything. If this is possible it
would also be quite useful while working with different instances of the
same .do file as a way of preventing an accidental overwrite in a
different instance. Any insight on this issue would be appreciated.

Sincerely,
Matthew Clifford

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