MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / runMacro

Method runMacro

ij/src/main/java/ij/plugin/Macro_Runner.java:174–190  ·  view source on GitHub ↗

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

(String macro, String arg)

Source from the content-addressed store, hash-verified

172 Returns the string value returned by the macro, null if the macro does not
173 return a value, or "[aborted]" if the macro was aborted due to an error. */
174 public String runMacro(String macro, String arg) {
175 Interpreter interp = new Interpreter();
176 try {
177 return interp.run(macro, arg);
178 } catch(Throwable e) {
179 interp.abortMacro();
180 IJ.showStatus("");
181 IJ.showProgress(1.0);
182 ImagePlus imp = WindowManager.getCurrentImage();
183 if (imp!=null) imp.unlock();
184 String msg = e.getMessage();
185 if (e instanceof RuntimeException && msg!=null && e.getMessage().equals(Macro.MACRO_CANCELED))
186 return "[aborted]";
187 IJ.handleException(e);
188 }
189 return "[aborted]";
190 }
191
192 /** Runs the specified macro from a JAR file in the plugins folder,
193 passing it the specified argument. Returns the String value returned

Callers 4

runMacroMethod · 0.95
runMacroFileMethod · 0.95
runMacroFromIJJarMethod · 0.95
runMacroFromJarMethod · 0.45

Calls 9

runMethod · 0.95
abortMacroMethod · 0.95
showStatusMethod · 0.95
showProgressMethod · 0.95
getCurrentImageMethod · 0.95
unlockMethod · 0.95
handleExceptionMethod · 0.95
getMessageMethod · 0.45
equalsMethod · 0.45

Tested by

no test coverage detected