Re: Macro errors are ignored in many cases

Posted by Wayne Rasband-2 on
URL: http://imagej.273.s1.nabble.com/Macro-errors-are-ignored-in-many-cases-tp5021683p5021685.html

> On Jan 22, 2019, at 5:01 AM, Stein Rørvik <[hidden email]> wrote:
>
> The release notes of 1.52j says
> "errors in macro run() statements are now reported using a "Macro Error" dialog that displays the line number."
>
> While useful in itself, it seems that this fix has introduced other problems.
> Many errors now do not stop the macro running but lets it continue with unexpected results.

These regressions are fixed in the latest daily build (1.52k63).

-wayne

> In the demo macro below, only case 5 works as it should.
> The difference between case 4 and case 5 is that the latter has no parameters, and may give a hint to where the problem is.
> Case 2 is especially dangerous. Case 3 is perhaps not really an error, just an inconvenience.
>
> The errors in the demo macro aborts correctly in 1.52i so it is the above change in error handling that has caused the problem.
>
> Demo macro:
> ------------------------------
>
> //case 1
> run("Blobs (25K)");
> run("Clear", "slice");
> //the command is invalid due to no selection, but the macro proceeds as if nothing happened
>
> //case 2
> run("T1 Head (2.4M, 16-bits)");
> saveAs("GIF", getDirectory("temp") + "T1-Head.gif");
> //command is invalid since 16-bit images cannot be saved as GIF
> //throws no error, instead just produces an empty file and proceeds macro execution
>
> //case 3
> run("T1 Head (2.4M, 16-bits)");
> run("Gif...");
> //command is invalid since 16-bit images cannot be saved as GIF
> //asks for filename; an empty file is generated
> //then the interpreter throws an error and aborts macro
> //the error should perhaps have appeared before asking for filename
>
> //case 4
> run("Close All");
> run("Scale...", "x=0.5 y=0.5");
> //command is invalid because no images are open
> //the macro is aborted silently with no error
>
> //case 5
> run("Close All");
> run("Scale...");
> //command is invalid because no images are open
> //the macro is aborted properly with an error
>
> ------------------------------
>
>
> I am using daily build ImageJ 1.52k with Java 1.6 on Windows 7/64-bit.

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