Posted by
Michael Schmid on
Dec 14, 2018; 8:54pm
URL: http://imagej.273.s1.nabble.com/Question-about-Tables-tp5021574p5021575.html
On 14.12.18 20:14, Craig Uhrich wrote:
> I don't see a way for a macro to determine if a certain Table already
exists.
> The obvious solution is to have a Table.exists() function, but that
doesn't seem to be available.
> Is there a common workaround trick?
Hi Craig,
there is a workaround, but one needs to get the table into the foreground:
title="My Table";
type="";
if (isOpen(title)) {
selectWindow(title);
type=getInfo("window.type");
}
if (type=="ResultsTable")
showMessage("Yes, we have a table named "+title);
If you are sure that nothing but a table can have the given title, of
course you can simply use isOpen(title).
When adding a new macro function (if there is not better alternative
already that I am not aware of), I would prefer a function that also
works for other Window types.
E.g.
getWindowType(windowTitle)
(which would return a blank String or, e.g. "ERROR" if there is no such
window), or
isOpen(windowTitle, windowType)
(which would check whether the window is open AND has the specified type) or
getList("window.titles", windowType)
which would only return the windows of the given type, and we would need
an additional
Array.contains(array, value)
or
Array.firstIndexOf(array, value)
macro function (the latter would return -1 if there is no such array
element)
Michael
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html