problem with ResultsTable.open() in javascript

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

problem with ResultsTable.open() in javascript

lechristophe
HI,

I used to start one of my scripts with the following code to retrieve
a results table from a tab-delimited text file:

od = new OpenDialog("Choose Results Table", "");
var rtpath = od.getDirectory() + od.getFileName();
rt = ResultsTable.open(rtpath);
var ln = rt.getCounter();
IJ.log(ln);


However I now have the following error :

org.mozilla.javascript.EcmaError: TypeError: Cannot call method
"getCounter" of null (New_.js#4)

meaning that ResultsTable.open() does not seem to return a results
table anymore ?

Thanks for your help,

Christophe

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: problem with ResultsTable.open() in javascript

Michael Schmid
Hi Christophe,

maybe the file that you open as a ResultsTable does not only contain numeric data values?
(exception: first column named 'Label')

In such a case, ResultsTable.open returns null and creates a text window with the file.

It may also return null if it can't read the table for other reasons, so you should create an error if rt is null.

[By the way, ResultsTable.open("") would also display an open dialog]


Michael
________________________________________________________________
On Jun 14, 2012, at 14:41, Christophe Leterrier wrote:

> HI,
>
> I used to start one of my scripts with the following code to retrieve
> a results table from a tab-delimited text file:
>
> od = new OpenDialog("Choose Results Table", "");
> var rtpath = od.getDirectory() + od.getFileName();
> rt = ResultsTable.open(rtpath);
> var ln = rt.getCounter();
> IJ.log(ln);
>
>
> However I now have the following error :
>
> org.mozilla.javascript.EcmaError: TypeError: Cannot call method
> "getCounter" of null (New_.js#4)
>
> meaning that ResultsTable.open() does not seem to return a results
> table anymore ?
>
> Thanks for your help,
>
> Christophe
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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