Window stopbox: R U SURE?


I sometimes inadvertently run some do-files. This is usually not a problem, but in some cases I find this irritating. Today, for example, I double-clicked on a wrong do-file that downloads data from UN Comtrade and saves these data as Stata files (see ComtradeTools and Stata). As UN Comtrade data is frequently updated, this could be a problem. Good thing I have only downloaded the data yesterday and that I have not used these for anything yet.

To avoid the same problem in the future, I wrote proceed.ado. This is a simple program that I can call at the beginning of some do-files that need caution before executing. This ado-file  uses -window stopbox- to prompt me with a message box whether to proceed or not with the execution (this idea I got from Eric Booth when he suggested the use of -window stopbox- in Proxy settings in Stata). Next time, when I unwittingly run do-files with -proceed- at the beginning, I have the option not to continue. If I choose not to proceed, Stata terminates and exits. Otherwise, Stata will read and execute the rest of the do-file.

You may ask, “Why not just use the -break- key?” Because in some do-files I first create a blank file to which I append the files I later generate. This means I already lost the file I needed most in the first few lines of the do-file. Now, I think I need to change this practice as well…

The ado-file for -proceed-, which I saved in C:\ado\personal, looks like this:

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
program define proceed
version 11

capture window stopbox rusure “Do you want to proceed?” ///
“This do-file takes hours to run or will overwrite important files.”

if _rc == 0 {
exit
}
else{
exit, STATA
}
end
*- – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – -*

See -help window stopbox-.

3 Responses

  1. I simply instucted Windows to open do-files with my text editor (TextPad) instead of Stata (which will run them); I prefer to run the do-files from within the do-file anyway.

  2. Reminds me that there is a version of the text editor Vi with a very intrusive assistant, Windows style.

    http://vigor.sourceforge.net/screenshots/

    gives the flavour.

Leave a Reply