Forward slashes do not work for default directories

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

Forward slashes do not work for default directories

Stein Rørvik
I need to set the default directory for saving both images and text in a macro.
According to various mailing list postings this can be done using a javascript call to
ij.io.OpenDialog.setDefaultDirectory for images and ij.plugin.frame.Editor.setDefaultDirectory for text.

The problem is that it does not work for me if the filepath is using forward slashes.
I prefer to use forward slashes as they are far more compatible and do not need escaping.
I am using daily build ImageJ 1.51s on Windows 7 64-bit.

Here is a test macro illustrating what I want to do:

//The following does not work:
dir = "C:/Users/steinr/ImageJ/Files/";
call("ij.plugin.frame.Editor.setDefaultDirectory", dir);
call("ij.io.OpenDialog.setDefaultDirectory", dir);
//saveAs path for both Text windows and images are set to the last used directory for saving

//The following works as expected:
dir = "C:\\Users\\steinr\\ImageJ\\Files\\";
call("ij.plugin.frame.Editor.setDefaultDirectory", dir);
call("ij.io.OpenDialog.setDefaultDirectory", dir);
//saveAs path for both Text windows and images are now set to the desired directory

Can this be fixed, or is it a limitation of Java / Windows?

Stein

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

Re: Forward slashes do not work for default directories

Aryeh Weiss
I suggest you use the File.separator macro command, which returns the
filename separator. It is a bit of a hassle to concatenate it in, but it
makes your code work on systems with different file separators.

--aryeh

On 13/11/2017 16:53, Stein Rørvik wrote:

> I need to set the default directory for saving both images and text in a macro.
> According to various mailing list postings this can be done using a javascript call to
> ij.io.OpenDialog.setDefaultDirectory for images and ij.plugin.frame.Editor.setDefaultDirectory for text.
>
> The problem is that it does not work for me if the filepath is using forward slashes.
> I prefer to use forward slashes as they are far more compatible and do not need escaping.
> I am using daily build ImageJ 1.51s on Windows 7 64-bit.
>
> Here is a test macro illustrating what I want to do:
>
> //The following does not work:
> dir = "C:/Users/steinr/ImageJ/Files/";
> call("ij.plugin.frame.Editor.setDefaultDirectory", dir);
> call("ij.io.OpenDialog.setDefaultDirectory", dir);
> //saveAs path for both Text windows and images are set to the last used directory for saving
>
> //The following works as expected:
> dir = "C:\\Users\\steinr\\ImageJ\\Files\\";
> call("ij.plugin.frame.Editor.setDefaultDirectory", dir);
> call("ij.io.OpenDialog.setDefaultDirectory", dir);
> //saveAs path for both Text windows and images are now set to the desired directory
>
> Can this be fixed, or is it a limitation of Java / Windows?
>
> Stein
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
Aryeh Weiss
Faculty of Engineering
Bar Ilan University
Ramat Gan 52900 Israel

Ph:  972-3-5317638
FAX: 972-3-7384051

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

Re: Forward slashes do not work for default directories

Wayne Rasband-2
In reply to this post by Stein Rørvik
> On Nov 13, 2017, at 9:53 AM, Stein Rørvik <[hidden email]> wrote:
>
> I need to set the default directory for saving both images and text in a macro.
> According to various mailing list postings this can be done using a javascript call to
> ij.io.OpenDialog.setDefaultDirectory for images and ij.plugin.frame.Editor.setDefaultDirectory for text.
>
> The problem is that it does not work for me if the filepath is using forward slashes.
> I prefer to use forward slashes as they are far more compatible and do not need escaping.
> I am using daily build ImageJ 1.51s on Windows 7 64-bit.

This bug is fixed in the latest ImageJ daily build (1.51s23).

-wayne


> Here is a test macro illustrating what I want to do:
>
> //The following does not work:
> dir = "C:/Users/steinr/ImageJ/Files/";
> call("ij.plugin.frame.Editor.setDefaultDirectory", dir);
> call("ij.io.OpenDialog.setDefaultDirectory", dir);
> //saveAs path for both Text windows and images are set to the last used directory for saving
>
> //The following works as expected:
> dir = "C:\\Users\\steinr\\ImageJ\\Files\\";
> call("ij.plugin.frame.Editor.setDefaultDirectory", dir);
> call("ij.io.OpenDialog.setDefaultDirectory", dir);
> //saveAs path for both Text windows and images are now set to the desired directory
>
> Can this be fixed, or is it a limitation of Java / Windows?

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

Re: Forward slashes do not work for default directories

Stein Rørvik
Thanks for the quick fix, works great!

Stein

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Wayne Rasband
Sent: 14. november 2017 00:07
To: [hidden email]
Subject: Re: Forward slashes do not work for default directories

> On Nov 13, 2017, at 9:53 AM, Stein Rørvik <[hidden email]> wrote:
>
> I need to set the default directory for saving both images and text in a macro.
> According to various mailing list postings this can be done using a
> javascript call to ij.io.OpenDialog.setDefaultDirectory for images and ij.plugin.frame.Editor.setDefaultDirectory for text.
>
> The problem is that it does not work for me if the filepath is using forward slashes.
> I prefer to use forward slashes as they are far more compatible and do not need escaping.
> I am using daily build ImageJ 1.51s on Windows 7 64-bit.

This bug is fixed in the latest ImageJ daily build (1.51s23).

-wayne


> Here is a test macro illustrating what I want to do:
>
> //The following does not work:
> dir = "C:/Users/steinr/ImageJ/Files/";
> call("ij.plugin.frame.Editor.setDefaultDirectory", dir);
> call("ij.io.OpenDialog.setDefaultDirectory", dir); //saveAs path for
> both Text windows and images are set to the last used directory for
> saving
>
> //The following works as expected:
> dir = "C:\\Users\\steinr\\ImageJ\\Files\\";
> call("ij.plugin.frame.Editor.setDefaultDirectory", dir);
> call("ij.io.OpenDialog.setDefaultDirectory", dir); //saveAs path for
> both Text windows and images are now set to the desired directory
>
> Can this be fixed, or is it a limitation of Java / Windows?

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

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