Strings in the results table?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Strings in the results table?

Gabriel Landini
Hi. Does anybody know any tricks to store from a macro, a column of strings in
the results table so then they can be later retrieved with getResult() or
similar?

I do not mean the write() function (which writes to the result window, not the
table), but something like setResult().
Actually one can attempt to set a string using setResult("Column", i), but it
appears in the table as NaN, so obviously it is not loaded.

In a plugin I could use rt.setLabel(label, i) to set a row label, so I could
use this space to store the string, but I cannot find out how to do this  (or
how to retrieve it if it could be set) from a macro...

Could the call() function be used for this? Something like:
call("ij.measure.ResultsTable.setLabel", "test", 4);

Any suggestions?

Regards,

Gabriel
Reply | Threaded
Open this post in threaded view
|

Re: Strings in the results table?

Wayne Rasband
Use setResult("Label", i, "a string") to write a string to the first
column of the results table. Here is an example:

      run("Clear Results");
      for (i=0; i<=10; i++) {
         setResult("Label", i, "Label"+i);
         setResult("Value", i, 1.234*i);
       }
      updateResults()

      for (i=0; i<=10; i++)
          print(getResultLabel(i)+": "+getResult("Value", i));

-wayne

On Nov 15, 2007, at 10:49 AM, Gabriel Landini wrote:

> Hi. Does anybody know any tricks to store from a macro, a column of
> strings in
> the results table so then they can be later retrieved with getResult()
> or
> similar?
>
> I do not mean the write() function (which writes to the result window,
> not the
> table), but something like setResult().
> Actually one can attempt to set a string using setResult("Column", i),
> but it
> appears in the table as NaN, so obviously it is not loaded.
>
> In a plugin I could use rt.setLabel(label, i) to set a row label, so I
> could
> use this space to store the string, but I cannot find out how to do
> this  (or
> how to retrieve it if it could be set) from a macro...
>
> Could the call() function be used for this? Something like:
> call("ij.measure.ResultsTable.setLabel", "test", 4);
>
> Any suggestions?
>
> Regards,
>
> Gabriel
>