Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: to preserve locals while debugging


From   <[email protected]>
To   <[email protected]>
Subject   st: to preserve locals while debugging
Date   Fri, 19 Mar 2010 12:18:09 +0100

Hi Statalisters,

I'm looking for a way to preserve locals while writing or debugging a
do-file . 

An example: 

I create a series of graphs in a loop. 
Graph parameters are provided by locals 
which are set inside the loop or somewhere else in the do-file.

Graph layout sometimes needs a lot of fine-tuning and visual checks.

Before running the graph again I have to redefine locals either 
by running the whole do-file or by temporarily defining all locals 
just above the graph command. Both alternatives are not very convenient.

I think of a command that stores all locals in a safe place 
(copy to global or something else) and breaks execution of the do file.

A complementary command restores the locals and makes them available for
the graph.

Anything already available or any ideas (beside "use globals")? ;-)

Stefan Gawrich



Simple code example 

sysuse auto, clear
local filename "auto.dta"
local foreign = 1
forval x = 1/5 {
lpres // preserves locals for the session and breaks at run 1 
...
}


To run while working on the graph:

lrest // restores locals
hist length if foreign == `foreign' & rep78 == `x', ///
title("`filename'")
}






*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index