Just to add to the collection of tricks: there is an undocumented
command -di_g- which is a conditional display. In normal mode it
displays nothing, but in the debug mode it displays the message. To
change the mode type: set di_g {on|off}. See -help di_g- for details.
The use is quite obvious: put a handful of these di_g's in the program
with messages like "Checkpoint alpha", "Checkpoint bravo", .....etc,
perhaps including the key locals to keep track of what's going on.
Best, Sergiy Radyakin
On Mon, Jan 12, 2009 at 8:10 PM, David Elliott <[email protected]> wrote:
> I agree as well. Simply saying "you screwed up just about here" would
> be a great help. I've used interpreted scripting languages that gave
> error messages like:
>
> display in puce "This is not an official colour"
> ^ I don't understand what you meant here.
>
> and they are certainly more helpful as to where the error occurred.
> Having a dump of the local environment at the time of the error would
> be helpful as well. A -mac dir- will often give clues to what has
> gone wrong.
>
> Incidentally, I'll share a little programming trick I use.
>
> As part of my syntax when developing a program I'll have a debug
> option and then a couple of statements like:
>
> local star *
> if "`debug'" == "debug" { local star }
>
> then in the program I'll have:
>
> `star' mac dir
>
> or
>
> `star' set trace on
>
> to track macros and code through problematic section. The `star'
> macro comments out the debugging statements unless debug is on.
>
> Without the debug option everything runs normally, with debug on, you
> can get a lot of feedback at chosen spots.
>
>
> --
> David Elliott
> *
> * 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/