Re: How to have File.openAsString() start in a specified directory?
Posted by
Wayne Rasband-2 on
Nov 28, 2018; 2:05am
URL: http://imagej.273.s1.nabble.com/How-to-have-File-openAsString-start-in-a-specified-directory-tp5021503p5021504.html
> On Nov 27, 2018, at 4:32 PM, Bill Christens-Barry <
[hidden email]> wrote:
>
> I would like to choose and open a (text) file that is in a particular directory of my choosing. I've not found a way to have the open dialog begin in this directory unless it happens to have been the most recently visited directory. The File.openAsString() macro function needs either a complete path that includes the file name, or a null path, in which case the user must navigate to the desired directory before choosing the file. But I've not found a way to have the open dialog start where I'd like, as the OS seems to control the initial path that is used by the dialog (on macos at least).
>
> Can this be done with existing macro functions?
Use the call() macro function to call OpenDialog.setDefaultDirectory(dir), as in this example:
dir = "/Users/wayne/Downloads/";
call("ij.io.OpenDialog.setDefaultDirectory", dir);
s = File.openAsString("");
print(s);
-wayne
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html