Statalist The Stata Listserver

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

Re: st: Integrating Stata and JEdit

From   "Dimitriy V. Masterov" <>
Subject   Re: st: Integrating Stata and JEdit
Date   Tue, 27 Jun 2006 00:40:33 -0400

I wanted to automate everything so that there's no switching between
windows, and the solution I came up with is a bit different than what
Ian Watson suggested, though it is basically a modified version of his

(1) Create a Bean Shell macro file called rundo.bsh in your jEdit
macro directory. On my PC, the directory is C:\Documents and
Settings\Dimitriy V. Masterov\.jedit\macros\. Rundo.bsh will save the
current do-file and then run the whole thing. Here's the code:

/** This Bean Shell jEdit script
(a) Saves the current do-file
(b) Runs it using Stata and an AutoIt script called rundo.exe

AutoIt is available at
See F. Huebler's Script 1 at for details on
rundo.exe **/

rundo() {
	// Get the name of the current do-file
      filename = buffer.getPath();

      // Save the do-file,null,true);

      // Runs the file. You many need to change the location of
rundo.exe to suit your PC
      String command="C:\\Program Files\\Scripts\\rundo.exe " + "\""
+ filename + "\"";


(2) To run only the highlighted part of the do-file, create another
script called rundolines.bsh:

/** This Bean Shell jEdit script runs the highlighted part of a Stata
do-file using an AutoIt script called rundo.exe.

AutoIt is available at
See F. Huebler's Script 1 at for details on
rundo.exe **/

rundolines() {
	// Copy selected text
	String text = textArea.getSelectedText();
	// Create a temp file
	File temp = File.createTempFile("dofilelines", ".do");
       // Delete temp file when program exits.
       // Write to temp file
       BufferedWriter out = new BufferedWriter(new FileWriter(temp));
	// Run the temporary file in Stata
	String command="C:\\Program Files\\Scripts\\rundo.exe " + "\"" + temp + "\"";


(3) To map F8 and F9 to the scripts, go to Utilities, Global Options,
Shortcuts, pick
Macros from the drop down menu, select the script name, and assign the
shortcut key.

*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index