Including a Beanshell Script in a Macro (.txt)

Hi everyone,

I’m currently working on a macro for image preprocessing.
I’m using a Beanshell script for Histogram Matching on a batch of images, and I would like to include it in my macro (.txt).

For the moment, I need to use the waitForUser() command to let the user opening the Beanshell Script, with the Script Editor of Fiji that can read it, which is not practical at all.

Do you know how to avoid that ?

Thank you so much in advance,

You can use the eval("bsh", "your script code in here") function, see the documentation of the macro functions.

1 Like

Hm, what’s the full script code you’re trying to run?

The following works for me when running from the script editor and choosing Language > IJ1 Macro:

eval("bsh", "import ij.IJ; IJ.log(\"test\");");

Anyways, I figured you might want to run the script from a file instead of including the raw code. See this other discussion where you asked this:


Yes, running the script from a file is much more practical, this is what I’m doing.
Thanks for your help, it was very kind of you.


1 Like