Hi,
On Nov 27, 2011, at 6:28 PM, Norbert Vischer wrote:
> When I run the macro below, I get an error after the first few runs.
> getImageID does not correctly return the ID of the plot window. Is there any fix or work-around?
>
> Norbert Vischer
>
>
> run("Close All");
> run("Blobs (25K)");
> srcID = getImageID;
>
> for (jj = 0; jj < 100; jj++){
> selectImage(srcID);
> yValues = newArray(2, 2.8, 4, 5.6, 8);
> Plot.create("Simple Plot", "X", "Y", yValues);
> Plot.show;
> plotID = getImageID;
> if (srcID == plotID)
> exit("Error: srcID == plotID; jj =" + jj);
> close;
> }
I suspect that a plot window does not qualifies as an image window in the macro language. Thus, the getImageID() and close() commands might not work as expected.
These modifications work on IJ 1.45m15 Mac OSX. There may be a better way but I can't think of any just now.
run("Close All");
run("Blobs (25K)");
srcID = getImageID;
for (jj = 0; jj < 100; jj++){
selectImage(srcID);
yValues = newArray(2, 2.8, 4, 5.6, 8);
Plot.create("Simple Plot", "X", "Y", yValues);
Plot.show;
//plotID = getImageID;
//if (srcID == plotID)
// exit("Error: srcID == plotID; jj =" + jj);
selectWindow("Simple Plot"); // <--- use selectWindow(title) for non-images
run("Close"); // <--- use run("Close") for non-images
}
Cheers,
Ben