Module ij
Package ij.plugin

# Class Macro_Runner

java.lang.Object
ij.plugin.Macro_Runner

All Implemented Interfaces:
  `PlugIn`

public class Macro_Runner extends Object implements PlugIn
This class runs macros and scripts installed in the Plugins menu as well as macros and scripts opened using the Plugins/Macros/Run command.

## Constructor Summary

Constructors
Constructor
Description
`Macro_Runner()`

## Method Summary

Modifier and Type
Method
Description
`static boolean`
`downloadJar(String url)`
`static String`
`getFilePath()`
Returns the file path of the most recently loaded macro or script.
`void`
`run(String name)`
Opens and runs the specified macro file (.txt or .ijm) or script file (.js, .bsh or .py) on the current thread.
`static String`
`runBeanShell(String script, String arg)`
Runs a BeanShell script on the current thread, passing a string argument, which the script can retrieve using the getArgument() function.
`String`
`runJavaScript(String script, String arg)`
Runs a JavaScript script on the current thread, passing a string argument, which the script can retrieve using the getArgument() function.
`String`
`runMacro(String macro, String arg)`
Runs the specified macro on the current thread.
`String`
`runMacroFile(String name, String arg)`
Opens and runs the specified macro or script on the current thread.
`String`
`runMacroFromIJJar(String name, String arg)`
`static String`
`runMacroFromJar(String name, String arg)`
Runs the specified macro from a JAR file in the plugins folder, passing it the specified argument.
`static String`
`runPython(String script, String arg)`
Runs a Python script on the current thread, passing a string argument, which the script can retrieve using the getArgument() function.
`static void`
`setFilePath(String path)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### Macro_Runner

public Macro_Runner()

## Method Details

### run

public void run(String name)
Opens and runs the specified macro file (.txt or .ijm) or script file (.js, .bsh or .py) on the current thread. Displays a file open dialog if `name` is an empty string. The macro or script is assumed to be in the ImageJ plugins folder if `name` is not a full path.

Specified by:
  `run` in interface `PlugIn`

### runMacroFile

public String runMacroFile(String name, String arg)
Opens and runs the specified macro or script on the current thread. The file is assumed to be in the ImageJ/macros folder unless 'name' is a full path. The macro or script can use the getArgument() function to retrieve the string argument.

### runMacro

public String runMacro(String macro, String arg)
Runs the specified macro on the current thread. Macros can retrieve the optional string argument by calling the getArgument() macro function. Returns the string value returned by the macro, null if the macro does not return a value, or "[aborted]" if the macro was aborted due to an error.

### runMacroFromJar

public static String runMacroFromJar(String name, String arg)
Runs the specified macro from a JAR file in the plugins folder, passing it the specified argument. Returns the String value returned by the macro, null if the macro does not return a value, or "[aborted]" if the macro was aborted due to an error. The macro can reside anywhere in the plugins folder, in or out of a JAR file, so name conflicts are possible. To avoid name conflicts, it is a good idea to incorporate the plugin or JAR file name in the macro name (e.g., "Image_5D_Macro1.ijm").

### runMacroFromIJJar

public String runMacroFromIJJar(String name, String arg)

### runJavaScript

public String runJavaScript(String script, String arg)
Runs a JavaScript script on the current thread, passing a string argument, which the script can retrieve using the getArgument() function. Returns, as a string, the last expression evaluated by the script.

### runBeanShell

public static String runBeanShell(String script, String arg)
Runs a BeanShell script on the current thread, passing a string argument, which the script can retrieve using the getArgument() function. Returns, as a string, the last expression evaluated by the script. Uses the plugin at http://imagej.nih.gov/ij/plugins/bsh/ to run the script.

### runPython

public static String runPython(String script, String arg)
Runs a Python script on the current thread, passing a string argument, which the script can retrieve using the getArgument() function. Returns, as a string, the value of the variable 'result'. For example, a Python script containing the line "result=123" will return the string "123". Uses the plugin at http://imagej.nih.gov/ij/plugins/jython/ to run the script.

### downloadJar

public static boolean downloadJar(String url)

### getFilePath

public static String getFilePath()
Returns the file path of the most recently loaded macro or script.

### setFilePath

public static void setFilePath(String path)