Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: RE: Tracing dofile execution


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: Tracing dofile execution
Date   Tue, 9 Feb 2010 21:34:25 +0100

<>


Also note the very handy - ssc d tr- by Ben Jann. It is a prefix command,
you can also supply -hilite- strings to it.


HTH
Martin


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Eric Booth
Sent: Dienstag, 9. Februar 2010 21:29
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: RE: Tracing dofile execution

<>
On Feb 9, 2010, at 2:16 PM, Martin Weiss wrote:

> 
> <>
> 
> To be honest, I cannot see what the -program- adds to Stata in terms of
> functionality - you can -trace- the execution of a do-file. I am sure I am
> overlooking something...
> 

Also,  the -set trace- help file already includes options for modifying the
depth and hiliting.

Anyways, to answer your question, this won't work in OSX.  
The copy command in OSX is "cp" and has different options than DOS's "/y
/a".
(There is a "copy" command but it's not a file copy command, it's for kernal
copying.))

The "cp" command doesnt append files together before the copy, as is the
case in 
the DOS version of "copy".  There's probably other *nix commands to do this,
but it might be a better
idea if you can write them all into the same file from Stata using -file
write-.  Or you could add them together
first using something similar to "appendfile" (from SSC).
If you could get the OSX version of "cp" to do what you need, you could
write a platform specific command 
for each OS, something like:


if "`c(os)'" == "Windows" {
!copy "`top'"+"`using'"+"`bottom'" "`c(sysdir_personal)'dotemp.ado" /y /a
}

if "`c(os)'" == "MacOSX" {
!cp  "`top'"+"`using'"+"`bottom'" "`c(sysdir_personal)'dotemp.ado" -R
*( you'd need to explore the help file for "cp" to see if it could append
the files first)
}

~Eric

__
Eric A. Booth
Public Policy Research Institute
Texas A&M University
ebooth@ppri.tamu.edu
Office: +979.845.6754
Fax: +979.845.0249
http://ppri.tamu.edu


> 
> 
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of David Elliott
> Sent: Dienstag, 9. Februar 2010 20:35
> To: statalist@hsphsun2.harvard.edu
> Subject: st: Tracing dofile execution
> 
> A frequent frustration I have is not being able to have -set trace on-
> trace the executing lines of a dofile.  I've seen some discussions on
> the list regarding this but no definitive solutions.  Michael Blasnik
> created a little -stepdo- utility to emulate the trace function but it
> chokes on //comment lines and multiline commands.  I decided to stop
> whining and write a little utility of my own.  Basically, it turns the
> dofile into a temporary adofile and then runs it under -set trace on-
> conditions that can be user modified for depth and hiliting.  The
> output is identical to an adofile trace because it IS an adofile
> during the run.
> 
> x------------- begin code -------------x
> program define dodebug
> version 9.0
> 
> *! version 1.0.1  2010.02.09
> *! Run a do-file with trace
> *! by David C. Elliott
> 
> syntax using/ [, Depth(integer 1) Hilite(string)]
> 
> capture program drop dotemp
> 
> tempfile top bottom
> file open top using `"`top'"', write text
> file write top "program define dotemp" _n ///
>    "version 9" _n ///
>    `"noisily di "{res:{hline 10} begin debug {hline}}""' _n
> file close top
> 
> file open bottom using `"`bottom'"', write text
> file write bottom _n "set trace off" _n "end" _n
> file close bottom
> 
> !copy "`top'"+"`using'"+"`bottom'" "`c(sysdir_personal)'dotemp.ado" /y /a
> 
> set trace on
> set tracedepth `depth'
> set tracehilite "`hilite'"
> dotemp
> set trace off
> noisily di "{res:{hline 10} end debug {hline}}"
> erase "`c(sysdir_personal)'dotemp.ado"
> 
> end
> x------------- end code -------------x
> 
> This runs fine under Windows but I have no way of testing in Mac or
> *nix environments so I don't know if the file appending shell command
> will work in all settings.
> 
> I experimented with trying to -file write- above and below the
> existing text of a dofile without success leading me to apply the
> !copy kludge to wrap the dofile wolf in adofile sheep's clothing.  If
> someone can educate me how I could do this with -file write- in text
> mode, I'd be most grateful.
> 
> Feedback would be appreciated and if there is a favorable response
> regarding usefulness I may whip up a helpfile and submit this to SSC.
> 
> Regards,
> 
> David Elliott MD, MSc
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
> 
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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