Writing an array to disk

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

Writing an array to disk

Douglas Benn-2
I would be grateful for some help.

I have created a new array with 25,000 cells for storing numbers. I want to
write this array to disk but the saveAs(format,path) macro is expecting an
image or log window to be open. Do I have to print the entire file to the
log window in order to use saveAs(    ) or is there a more direct way of
writing a none-image array to disk?

Thank you.

Dr Douglas K Benn, BDS, M.Phil., Ph.D., Dipl. Dental Radiology (Royal
College of Radiologists, England).
Professor
Dept of General Dentistry
Creighton University Dental School
2500 California Plaza
Omaha
Nebraska 68178

Tel: (402)280 5025
Fax: (402)280 5094
Reply | Threaded
Open this post in threaded view
|

Re: Writing an array to disk

jmutterer
Hi,
Create a new file using File.open(path).
You can then use the print(file,data) function.
See the print function description at
http://rsbweb.nih.gov/ij/developer/macro/functions.html#print
and the demo macro at http://rsb.info.nih.gov/ij/macros/SaveTextFileDemo.txt
Jerome

// writing an array to a file
a = newArray("test",1,2,"end");
dir = getDirectory('home');
name = "yourFile.txt";
file = File.open(dir+name);
for (i=0;i<a.length;i++) print (file,a[i]);
File.close(file);




On Tue, Feb 16, 2010 at 9:53 PM, Douglas Benn <[hidden email]>
wrote:
>
> I would be grateful for some help.
>
> I have created a new array with 25,000 cells for storing numbers. I want
to

> write this array to disk but the saveAs(format,path) macro is expecting an
> image or log window to be open. Do I have to print the entire file to the
> log window in order to use saveAs(    ) or is there a more direct way of
> writing a none-image array to disk?
>
> Thank you.
>
> Dr Douglas K Benn, BDS, M.Phil., Ph.D., Dipl. Dental Radiology (Royal
> College of Radiologists, England).
> Professor
> Dept of General Dentistry
> Creighton University Dental School
> 2500 California Plaza
> Omaha
> Nebraska 68178
>
> Tel: (402)280 5025
> Fax: (402)280 5094