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)
| 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 |
no test coverage detected