Statalist


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

Re: st: Does a do file know its own name?


From   "Sergiy Radyakin" <serjradyakin@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Does a do file know its own name?
Date   Fri, 17 Aug 2007 10:40:55 -0400

Hi,

I just wanted to add to this discussion, that the problem would have
been easily resolved if user-written commands had priority over
built-in commands. Currently, the presence of "do.ado" in the ADOPATH
makes no difference, and the built-in command gains control after "do
dofile". Being able to override built-in commands similar to the way
it is done with the external commands (stored in .ado files) would
further increase flexibility of Stata: all older programs will receive
new features simultaneously without any changes in their code (e.g.
then I might override "save" command to log the filename and user's ID
to track changes to files, or mirror backup copies, etc). I think this
could be implemented by adding built-in identifier (say symbol *) to
ADOPATH lines (note that * may not be a part of a filename in
Windows), the user then can determine priorities on her own, by
ordering the paths in ADOPATH.

Best regards,
  Sergiy

On 8/17/07, Skinner Jane Dr (MED) <Jane.Skinner@uea.ac.uk> wrote:
> Many thanks to everybody who replied.  I have installed dolog -
> thanks, Roger!  (It's essentially the same as Nick's suggestion,
> with some further refinements.)
>
> I would like to add my voice to those who would like to see a
> "currently running" section accessible by creturn.  I quite often
> write customised output to csv files, and it would be nice if these
> could have the same name as their do-file creators, without the
> necessity of having a wrapper command to run do files with filenames
> as arguments.
>
> Best wishes,
>
> Jane
>
> Roger Newson wrote:
> > If you want a version of -do- (renamed appropriately) that
> > creates the log file (named appropriately), then download the
> > -dolog- package from SSC by typing
> >
> > ssc desc dolog
> > ssc inst dolog, replace
> >
> > If you then type
> >
> > dolog mydofile
> >
> > then Stata will execute -mydofile.do- and output the results to
> > -mydofile.log- (as well as echoing them to the Results window).
> >
> > I hope this helps.
> >
> > Roger
> >
> >
> > -----Original Message-----
> > From: owner-statalist@hsphsun2.harvard.edu
> > On Behalf Of Austin Nichols
> > Sent: 16 August 2007 17:18
> > To: statalist@hsphsun2.harvard.edu
> > Subject: Re: st: Does a do file know its own name?
> >
> > Jane--
> > As far as I know, no. This would be a natural addition though,
> > and I have heard at least one request for this at Users Group
> > meeting.
> >
> > Try
> >   creturn list
> > to see where a section on "Currently running" or somesuch would
> > be natural, with perhaps:
> >             c(dofilename) = ""
> >             c(dofilepath) = ""
> >             c(adofilename) = ""
> >             c(adofilepath) = ""
> >
> > One workaround for do-files is to create your own versions of
> > -do- and -run- (renamed appropriately) that create the log file
> > and then -do- or -run- the do-file. Another option is to use
> > batch-mode processing which creates a do-file of the same name by
> > default, and also runs a whole lot faster.
> >
> > On 8/16/07, Skinner Jane Dr (MED) <Jane.Skinner@uea.ac.uk> wrote:
> >> Hi
> >>
> >> Is there any way of obtaining the string "MyDoFile"
> >> programmatically from within MyDoFile.do?  I would like to write
> >> to a log file with the same name (different extension,
> >> obviously) in a way that is robust to renaming or copying the do
> >> file, amongst other things.
> >>
> >> Thanks,
> >>
> >> Jane
> --
> Dr Jane Skinner
> School of Medicine, Health Policy & Practice
> University of East Anglia, Norwich NR4 7TJ
> E-mail: jane.skinner@uea.ac.uk  Tel: 01603 593120
> *
> *   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/
>
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index