[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: RE: Function that writes the location of the current do-file ?
You can pass arguments to a do file. This is
explicit in the on-line help and explained
in more detail at [U] 16.6.
The main idea is that the first, second,
... argument are mapped to local macros
1, 2, ... .
So for example
do frog "c:/project/data"
could work with
The successive arguments are delimited
by white space, except that quotes bind.
do frog "c:/windows people prefer long names with spaces"
"c:/windows people prefer long names with spaces"
is all the first argument.
> Usually, when writing a do file, the first lines are like this:
> set mem..
> set more off..
> cd c:/project/data // !!!!!!
> The problem is that, when using the do files on different computers,
> or giving the data + do-files to a colleague, they have to change each
> do-file to match the location of the data (ie, change cd
> c:/project/data to cd "c:/my documents/john/reviews/data")
> My question is, is there a way to do something like
> cd `currentdofile'
> Where `currentdofile' gives the path to the do file currently running.
> Assuming that the do files are in a folder like
> c:/project/prg , then I can
> cd ..
> cd data
> And I don't longer have to update locations if the path changes.
> I'm aware that other languages do this, but i don't know if there is
> any way to do this in Stata.
* For searches and help try: