Posted by
Jan Eglinger on
Jul 22, 2014; 8:57am
URL: http://imagej.273.s1.nabble.com/run-and-Macro-Recorder-ignoring-calls-to-getBoolean-tp5008839p5008845.html
Hi Neil,
On 21.07.2014, 9:25 PM, Neil Fazel wrote:
> I often invoke one .ijm macro from within another with help from the Macro Recorder. I first run the called macro interactively, then copy and paste into another macro whatever the Macro Recorder displays in the Recorder window. The Macro Recorder embeds arguments provided interactively by the user in the argument string it passes to the called macro. For example, if the called macro is MyMacro.ijm, and has two getNumber() calls in it to get arg1 and arg2, the Recorder shows this
>
> run("MyMacro", "arg1=8349 arg2=55");
>
> But any calls to getBoolean() do not show up in the argument list, e.g. something like
>
> run("MyMacro", "arg1=8349 arg2=55 arg3=true");
>
> is not generated. I tried inserting arg3=true by hand into the run() statement, but it was ignored by the called macro.
>
> It would be nice if run() and Macro Recorder could handle Boolean arguments.
Boolean values (from dialog checkboxes) are recorded by the presence or
absence of the checkbox label in the argument string. Consider this macro:
Dialog.create("Dialog asking for boolean options");
Dialog.addCheckbox("Do_this", false);
Dialog.addCheckbox("Do_that", true);
Dialog.show();
opt1 = Dialog.getCheckbox();
opt2 = Dialog.getCheckbox();
print("opt1 = " + opt1 + "; opt2 = " + opt2);
If you save this as "Boolean_Macro_Demo.ijm" anywhere in your /plugins/
directory, you can call it from the menu after restart, and the recorder
will record commands such as:
run("Boolean Macro Demo", " do_that");
run("Boolean Macro Demo", "do_this");
run("Boolean Macro Demo", " ");
When both checkboxes are unchecked (false), just a space " " is recorded.
Hope that helps,
Jan
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html