Login  Register

Re: File.nameWithoutExtension

Posted by ctrueden on Mar 14, 2017; 2:24pm
URL: http://imagej.273.s1.nabble.com/File-nameWithoutExtension-tp5018290p5018293.html

Hi Kees,

I see similar behavior. What File.nameWithoutExtension function actually
does is to return the filename of the last file opened by the Open or Save
dialog or by drag and drop [1, 2]. Opening a sample image via Open Samples
does not open an image using one of those mechanisms, and so it does not
"count" for the purposes of File.nameWithoutExtension.

Regards,
Curtis

[1]
https://github.com/imagej/ImageJA/blob/v1.51j/src/main/java/ij/macro/Functions.java#L3892-L3899
[2]
https://github.com/imagej/ImageJA/blob/v1.51j/src/main/java/ij/io/OpenDialog.java#L240-L245

--
Curtis Rueden
LOCI software architect - https://loci.wisc.edu/software
ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden
Did you know ImageJ has a forum? http://forum.imagej.net/


On Tue, Mar 14, 2017 at 9:01 AM, Straatman, Kees (Dr.) <[hidden email]
> wrote:

> Dear list and Wayne,
>
> I recently noticed some problems with the function
> File.nameWithoutExtension()
>
> If I open Fiji or ImageJ and run the macro code:
>
> run("Blobs (25K)");
> title=File.nameWithoutExtension();
> print(title);
>
> I get as result: "test_"
>
> If I give this macro a name it will give as result the macro name.
>
> I can repeat this multiple times, the result is the same.
>
> If I open manually the blobs sample file, and run line 2 and 3 from the
> macro I get the same results.  If I open a locally saved file the result is
> "blobs". If I now run the 3 line macro again the results is "blobs", as
> expected
>
> However, if I close Fiji, restart and open my images and run line 2 and 3
> from the macro I get the macro name as result again.
>
> Can anybody confirm this behaviour?
>
> Best wishes
>
> Kees
>
> University of Leicester
> http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/AIF
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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