importClass(Packages.ij.plugin.Macro_Runner); var i = 42; mr = new Macro_Runner(); mr.runMacro("print(getArgument());", i);
/** Runs the macro contained in the string <code>macro</code>. The optional string argument can be retrieved in the called macro using the getArgument() macro function. Returns any 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. */ public static String runMacro(String macro, String arg) { Macro_Runner mr = new Macro_Runner(); return mr.runMacro(macro, arg); }
/** Runs the specified macro or script file in the current thread. The file is assumed to be in the macros folder unless <code>name</code> is a full path. The optional string argument (<code>arg</code>) can be retrieved in the called macro or script using the getArgument() function. Returns any string value returned by the macro, or null. Scripts always return null. The equivalent macro function is runMacro(). */ public static String runMacroFile(String name, String arg) { Macro_Runner mr = new Macro_Runner(); return mr.runMacroFile(name, arg); }
/** Runs the specified macro or script file in the current thread. The file is assumed to be in the macros folder unless <code>name</code> is a full path. The optional string argument (<code>arg</code>) can be retrieved in the called macro or script using the getArgument() function. Returns any string value returned by the macro, or null. Scripts always return null. The equivalent macro function is runMacro(). */ public static String runMacroFile(String name, String arg) { Macro_Runner mr = new Macro_Runner(); return mr.runMacroFile(name, arg); }
/** Runs the macro contained in the string <code>macro</code>. The optional string argument can be retrieved in the called macro using the getArgument() macro function. Returns any 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. */ public static String runMacro(String macro, String arg) { Macro_Runner mr = new Macro_Runner(); return mr.runMacro(macro, arg); }
return (new Macro_Runner()).runMacro(macro, arg); else return null;
return (new Macro_Runner()).runMacro(macro, arg); else return null;
String runMacro(boolean eval) { interp.getLeftParen(); String name = getString(); String arg = null; if (interp.nextToken()==',') { interp.getComma(); arg = getString(); } interp.getRightParen(); if (eval) { if (arg!=null && (name.equals("script")||name.equals("js"))) return (new Macro_Runner()).runJavaScript(arg, ""); else if (arg!=null && (name.equals("bsh"))) return Macro_Runner.runBeanShell(arg,""); else if (arg!=null && (name.equals("python"))) return Macro_Runner.runPython(arg,""); else return IJ.runMacro(name, arg); } else return IJ.runMacroFile(name, arg); }
String runMacro(boolean eval) { interp.getLeftParen(); String name = getString(); String arg = null; if (interp.nextToken()==',') { interp.getComma(); arg = getString(); } interp.getRightParen(); if (eval) { if (arg!=null && (name.equals("script")||name.equals("js"))) return (new Macro_Runner()).runJavaScript(arg, ""); else if (arg!=null && (name.equals("bsh"))) return Macro_Runner.runBeanShell(arg,""); else if (arg!=null && (name.equals("python"))) return Macro_Runner.runPython(arg,""); else return IJ.runMacro(name, arg); } else return IJ.runMacroFile(name, arg); }