/** 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. */ public static String runBeanShell(String script, String arg) { if (arg==null) arg = ""; Object bsh = IJ.runPlugIn("bsh", ""); if (bsh==null) { boolean ok = downloadJar("/plugins/bsh/BeanShell.jar"); if (ok) bsh = IJ.runPlugIn("bsh", ""); } if (bsh!=null) return runScript(bsh, script, arg); else return null; }
/** 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. */ public static String runBeanShell(String script, String arg) { if (arg==null) arg = ""; Object bsh = IJ.runPlugIn("bsh", ""); if (bsh==null) { boolean ok = downloadJar("/plugins/bsh/BeanShell.jar"); if (ok) bsh = IJ.runPlugIn("bsh", ""); } if (bsh!=null) return runScript(bsh, script, arg); else return null; }
/** 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. */ public static String runPython(String script, String arg) { if (arg==null) arg = ""; Object jython = IJ.runPlugIn("Jython", ""); if (jython==null) { boolean ok = downloadJar("/plugins/jython/Jython.jar"); if (ok) jython = IJ.runPlugIn("Jython", ""); } if (jython!=null) return runScript(jython, script, arg); else return null; }
/** 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. */ public static String runPython(String script, String arg) { if (arg==null) arg = ""; Object jython = IJ.runPlugIn("Jython", ""); if (jython==null) { boolean ok = downloadJar("/plugins/jython/Jython.jar"); if (ok) jython = IJ.runPlugIn("Jython", ""); } if (jython!=null) return runScript(jython, script, arg); else return null; }
/** 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. */ public String runJavaScript(String script, String arg) { Object js = null; if (!(IJ.isMacOSX()&&!IJ.is64Bit())) { // Use JavaScript engine built into Java 6 and later. js = IJ.runPlugIn("ij.plugin.JavaScriptEvaluator", ""); } else { js = IJ.runPlugIn("JavaScript", ""); if (js==null) { boolean ok = downloadJar("/download/tools/JavaScript.jar"); if (ok) js = IJ.runPlugIn("JavaScript", ""); } } script = Editor.getJSPrefix(arg)+script; if (IJ.isJava18()) script = "load(\"nashorn:mozilla_compat.js\");" + script; if (js!=null) return runScript(js, script, arg); else return null; }
/** 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. */ public String runJavaScript(String script, String arg) { Object js = null; if (!(IJ.isMacOSX()&&!IJ.is64Bit())) { // Use JavaScript engine built into Java 6 and later. js = IJ.runPlugIn("ij.plugin.JavaScriptEvaluator", ""); } else { js = IJ.runPlugIn("JavaScript", ""); if (js==null) { boolean ok = downloadJar("/download/tools/JavaScript.jar"); if (ok) js = IJ.runPlugIn("JavaScript", ""); } } script = Editor.getJSPrefix(arg)+script; if (IJ.isJava18()) script = "load(\"nashorn:mozilla_compat.js\");" + script; if (js!=null) return runScript(js, script, arg); else return null; }