Login  Register

Problem with "&variable" in run() macro statement

Posted by José María Mateos on Aug 27, 2013; 10:45am
URL: http://imagej.273.s1.nabble.com/Problem-with-variable-in-run-macro-statement-tp5004565.html

Hello everyone,

I am running a plugin that I have coded (using the GenericDialog
class, so the parameters can be passed from a macro) and I am
encountering a problem in the following line:

run("Average Frames", "first=1 last=&frames");

This plugin just does the averaging of an image using the first and
last frames passed as arguments. The "frames" variable is set, I have
checked. If I run this line in its current form, I get the following
error:

ImageJ 1.48a; Java 1.6.0_38-ea [64-bit]; Windows 7 6.1; 521MB of 4096MB (12%)
java.lang.NumberFormatException: For input string: "frames"
...

So, looks like the argument has been passed as a string and not as the
value content (the plugin, of course, expects a number). If instead I
use

run("Average Frames", "first=1 last=" + frames);

Everything works like a charm. I understod that the "&variable_name"
shortcut can be used inside the run() method and the variable_name
contents would be passed as the tool parameter. Am I missing something
here?

Best,

José.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html