get directory of text window?

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

get directory of text window?

Cammer, Michael
I am writing a macro where the user is prompted to open a file with tab delimited text in it.  The command

 open();

works fine and the command

 lines =  split(getInfo("window.contents"),'\n');

works perfectly too.



The command

  print(getInfo("window.type"));

reports that the file is opened as type Editor, not type Text, but this does not matter to us.



Question:

How can we get the directory that this open command operated on?  We want to save the results in the same directory as the text file.



I've tried a few different ways of getting this info, but the results are always null or of an open image, not of this text or editor window.



Thank you!!




_________________________________________
Michael Cammer, Optical Microscopy Specialist
http://ocs.med.nyu.edu/microscopy
http://microscopynotes.com/
Cell: (914) 309-3270

------------------------------------------------------------
This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is proprietary, confidential, and exempt from disclosure under applicable law. Any unauthorized review, use, disclosure, or distribution is prohibited. If you have received this email in error please notify the sender by return email and delete the original message. Please note, the recipient should check this email and any attachments for the presence of viruses. The organization accepts no liability for any damage caused by any virus transmitted by this email.
=================================

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

Re: get directory of text window?

Rasband, Wayne (NIH/NIMH) [E]
> On Jul 18, 2015, at 3:12 PM, Cammer, Michael <[hidden email]> wrote:
>
> I am writing a macro where the user is prompted to open a file with tab delimited text in it.  The command
>
> open();
>
> works fine and the command
>
> lines =  split(getInfo("window.contents"),'\n');
>
> works perfectly too.
>
> Question:
>
> How can we get the directory that this open command operated on?  We want to save the results in the same directory as the text file.

The File.directory macro function returns the directory path of the last file opened using a file open dialog and you can read the contents of a file without displaying it by using the File.openAsString(“") function. Here is an example:

  str = File.openAsString("");
  lines = split(str,"\n");
  dir = File.directory;

-wayne

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