Login  Register

Re: Bug report: File.directory () builtin function fails in -batch

Posted by Carnë Draug on Mar 14, 2014; 4:10pm
URL: http://imagej.273.s1.nabble.com/Bug-report-File-directory-builtin-function-fails-in-batch-tp5006917p5006920.html

On 14 March 2014 15:45, Johannes Schindelin <[hidden email]> wrote:

> Hi Carnë,
>
> On Fri, 14 Mar 2014, Carnë Draug wrote:
>
>> The macro builtin function "File.directory()" does not work when
>> starting ImageJ via command line -batch:
>>
>> 1) create a simple macro
>>
>> $ echo ''open (getArgument()); print (File.directory ());' >
>> ./macro_test.ijm
>
> I assume you meant a single single quote before the 'open'?

Yes, apologies for the mistake.

>> 2) see how File.directory() fails, displaying an empty message on the
>> log window
>>
>> $ ImageJ-linux32 -batch ./macro_test.ijm ./path_to_image
>
> Are you sure that this works in _non_ batch mode? It does not work here,
> and my investigation showed that only File.name is expected to work
> correctly:
>
>         https://github.com/imagej/imagej1/blob/644e33c43593d8d1af400f87cb05f7b368aff93e/ij/macro/Functions.java#L2434
>
> Note how OpenDialog.setLastName() is called but not
> OpenDialog.setLastDirectory().

Inspecting it further, it actually returns a completely wrong answer.
I start FIJI normally. I go to "File > Open..." and select a figure
that is *not* on the FIJI directory. Then, "Plugins > Macros > Run
..." and select a macro with the single line "print (File.directory
());". The log window appears with the path for the FIJI directory. I
originally had the image on the same directory as FIJI so I didn't
notice that it was giving the wrong value there either.

Carnë

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