Statalist


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

Re: st: creating keyboard shorcuts on windows


From   Phil Schumm <pschumm@uchicago.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: creating keyboard shorcuts on windows
Date   Wed, 9 Jul 2008 11:12:21 -0500

On Jul 9, 2008, at 10:10 AM, Murali Kuchibhotla wrote:
I have a question that is very similar to Andrea's previous post.I often write my code in a do-file with the delimiter turned on.This creates a problem for me when I am only interested in running a part of the code.If I select a portion of the code and click on the 'do-selection'tab in the tools option of the do-file editor I am confronted with the error message,"option ; not allowed".For lack of a better option I have to resort to copying the code from the do- file editor and pasting it in Stata's command window and then removing the ; symbol before running it, which is extremely tedious. Is there a better way to do this? Thanks.


Couple of comments. First, the obvious -- don't use delimiters. I acknowledge that some people prefer them, but, spending most of my time now in either Stata or Python, I've grown quite fond of the cleanliness of not having them. Especially when using a language interactively, once you've grown accustomed to not using them, being required to use them is a real pain.

If you're one of those people who has carefully considered this option and decided that you prefer to use delimiters, then there are at least two things you can do. First, you can modify the script that your text editor uses to send the selected commands to Stata so that it adds the following line at the beginning:

#delimit ;

Of course, that would cause problems if there are times when you don't want to use the delimiter. In that case, you could create two commands: one which sends the lines to Stata as-is, and the other which prepends the appropriate #delimit statement at the beginning. IOW, you would then have both "Run selection with semicolons" and "Run selection without semicolons."

Alternatively (and a bit more difficult to implement), since use of delimiters is optional in Stata, and, I'd bet, is practiced by a minority of users, if I used them I'd want to have some good utility functions which switched back and forth. IOW, a function that would go through my do-file and change

command
another command that ///
is continued

to

command;
another command that
is continued;

and vice-versa. Indeed, there may already be functions out there to do this. But I'd want to be able to call it from within my text editor, so that I could switch back-and-forth easily. Once you had this function, you could then alter your "Run selection" command to auto-sense whether your selected code was using delimiters or not, and, if so, then include the appropriate #delimit statement. I'm not sure at this point whether such implicit behavior would really be desirable -- the "2 commands" approach I described first might be the better approach (though I'd still want to have the ability to convert back and forth if necessary).


-- Phil

*
* 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