Login  Register

Re: Question about Tables

Posted by Michael Schmid on Dec 17, 2018; 5:48pm
URL: http://imagej.273.s1.nabble.com/Question-about-Tables-tp5021574p5021583.html

Hi Craig,

what I wanted to say: You have to live with it that my macro takes the
table into the foreground (if it exists).
E.g., if you have previously had something else in the foreground, and
you want to keep it in the foreground, you have to put it into the
foreground again after running my macro.

   title="TDI_Prec";
   type="";
   if (isOpen(title)) {
     selectWindow(title);    // put window "TDI_Prec" to foreground
     type=getInfo("window.type");  //get type of that window
   }
   if (type=="ResultsTable") // check whether it is a table
     showMessage("Yes, we have a table named "+title);

Your macro should also work well (as long as "TDI_Prec" is a table, not
something else). It is essentially equivalent to

   table_exists = isOpen("TDI_Prec");


Michael
________________________________________________________________
On 17.12.18 18:18, Craig Uhrich wrote:

> Michael,
> Thanks for your suggestion.   But I don't see how I can get the table to the foreground if the table doesn't exist.
>
> I cobbled together a workaround for my initial question using the existing getList("window.titles") function.
>
> // Create "TDI_Prec" table if it doesn't already exist
> t_name = "TDI_Prec";
> table_exists = false;
> wins = getList("window.titles");
> for (i=0; i<wins.length; i++) if (wins[i] == t_name) table_exists = true;
> if (table_exists) {
>    row = Table.size(t_name);
>    } else {
>    Table.create(t_name);
>    row = 0;
>    }
>
> It may not be elegant, but it creates the Table window if none exists, and allows me to append if the Table is already there.
>
>                     -Craig
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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