Statalist


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

Re: st: Apple Script to Comment Lines in Text Wranger/BBEdit


From   Steven Samuels <[email protected]>
To   [email protected]
Subject   Re: st: Apple Script to Comment Lines in Text Wranger/BBEdit
Date   Wed, 24 Sep 2008 00:33:55 -0400

-

1. Correction: I should well know that John did not write the scripts for submitting Stata commands--their author is Ben Hulley. See: http://dataninja.wordpress.com/2006/08/18/stata-scripts/

2. Michael: to get started with AppleScript, search for "applescript" in the Mac Help. To try a script from John's site, download and save it to the desktop. Double-click to open & look at it (see advice on John's site--you may have to choose your editor (BBEdit or TW) from a list). If you have a do file open, you can try the script by pushing the Run button.

In BBEdit or TW,, open the Script Folder (Scripts Menu), and move the script there. In the BBEdit Window Menu, find the Palattes SubMenu and the Scripts item. There all the scripts in the Scripts Folder will be listed. Assign a menu key combination to each and go. You use the scripts when a do-file is open in BBEdit or TW.

-Steve



BBEdit Scripts folder, and assign a menu key combination.

-Steve


On Sep 23, 2008, at 10:41 PM, Steven Samuels wrote:
hanks for the reference, Dave. Dataninja is John Gardner. I hadn't looked at the John's site for quite awhile, but your post prompted another visit.

There I discovered scripts that do exactly what mine does, only much faster. They are the GenericComment and GenericUncomment scripts (http://dataninja.wordpress.com/2006/05/08/textwrangler- uncomment-scripts-for-stata/). These script work out of the box not only with do-files, but also with R command files and LaTex files. It's a little embarrassing to find them for the first time, since I corresponded with John about using BBEdit with Stata. I use his scripts for submitting Stata commands (the URL in your post) and use his module for syntax coloring of do-files (http:// dataninja.wordpress.com/2006/02/28/stata-language-module-for- textwrangler/).

The Dataninja site is well worth a visit.

-Steve

On Sep 23, 2008, at 9:16 PM, David Airey wrote:



Also see the scripts for the purpose and platform/app combination at:

http://dataninja.wordpress.com/2006/08/18/stata-scripts/

-Dave

On Sep 23, 2008, at 1:25 PM, Steven Samuels wrote:


For Mac users who edit do-files in BBEdit or Text Wrangler, here's a
simple script to comment and uncomment lines in selected text. (Yes,
"uncomment" is in the dictionary). Although the script can be slow, I
find it saves me effort compared to inserting and deleting "/*" and
"*/" before and after a text block. Text Wrangler users, substitute
"Text Wrangler" in the tell statement. To use: open in BBEdit or TW,
zap gremline, insert into Script Editor, save the script into the
BBEdit Scripts folder, and assign a menu key combination.

-Steve


(*
Add & remove // in Selection
Activate with Menu Key
*)

tell application "BBEdit"
activate
repeat with x in lines of selection of window 1 of text document 1
if exists character 1 of text of x then
set start to character 1 of text of x as text
else
set start to ""
end if
if start is not "/" then
replace "^" using "// " searching in text of x options {search
mode:grep}
else
replace "^// " using "" searching in text of x options {search
mode:grep}
end if
end repeat
end tell


*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index