Posted by
Rasband, Wayne (NIH/NIMH) [E] on
Aug 27, 2013; 11:18pm
URL: http://imagej.273.s1.nabble.com/Problem-with-variable-in-run-macro-statement-tp5004565p5004583.html
On Aug 27, 2013, at 11:42 AM, José María Mateos wrote:
> 2013/8/27 Rasband, Wayne (NIH/NIMH) [E] <
[hidden email]>:
>> I am unable to duplicate this problem using this test plugin:
>>
>> import ij.*;
>> import ij.gui.*;
>> import ij.plugin.*;
>>
>> public class Average_Frames implements PlugIn {
>> int first=1, last=10;
>>
>> public void run(String arg) {
>> GenericDialog gd = new GenericDialog("Test Dialog");
>> gd.addNumericField("First frame: ", first, 0);
>> gd.addNumericField("Last frame: ", last, 0);
>
> Thanks for your answer, Wayne. I think I've found where we are
> diverging. My plugin (BTW, code at
>
https://github.com/HGGM-LIM/limtools/blob/master/src/main/java/limtools/Average_Frames.java)
> does not build its GUI with gd.addNumericField but with gd.addChoice
> (so I can limit the range of values the user can provide). Might it be
> a bug in the variable conversion when using the addChoice method?
The GenericDialog.getNextChoice() method expects a string so you can work around the problem by calling the plugin using a macro something like
frames = "5";
run("Average Frames", "first=1 last=&frames");
Or upgrade to the ImageJ 1.48c daily build, which converts numeric variables to strings, and you can use
frames = 5;
run("Average Frames", "first=1 last=&frames");
-wayne
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html