NOTICE! This is a static HTML version of a legacy Fiji BugZilla bug.

The Fiji project now uses GitHub Issues for issue tracking.

Please file all new issues there.

Bug 445 - Library.txt is not being loaded
Library.txt is not being loaded
Status: RESOLVED FIXED
Product: Fiji
Classification: Unclassified
Component: Other
unspecified
Macintosh Linux
: P2 normal
Assigned To: ImageJ Bugs Mailing List
Depends on:
Blocks:
 
Reported: 2012-07-02 21:28 CDT by Carnë Draug
Modified: 2015-04-07 07:41 CDT
3 users (show)

See Also:

Description Carnë Draug 2012-07-02 21:28:08 CDT
The file Library.txt is not being loaded at all. When I write a macro that uses one of its functions, I get the error "Undefined identifier" for the functions defined on Library.txt

I have tested this with the FIJI version on the Debian repositories (Debian squeeze with ImageJA 1.45i) and with the FIJI for linux available for download (ImageJA 1.45b).

I have checked the value of "Menus.getMacrosPath" and placed the Library.txt file on the correct place. I have both write and read permissions for the file (I even tried chmod 777).
Comment 1 Johannes Schindelin 2012-09-18 20:33:42 CDT
Should that not be macros/FunctionLibrary.txt?
Comment 2 Carnë Draug 2012-09-19 00:37:07 CDT
Not according to the manual. The ImageJ Macro Language Programmer’s Reference Guide v1.46d states on page 16:

"However, those functions that you want to be available from all macros can be included in special macro that is appended to any executed macro. This special macro must be available from the following location: ImageJ/macros/Library.txt .

In short, the ImageJ/macros/Library.txt macro is appended to any executed or installed macro."


I have reported this first on the ImageJ mailing list

http://imagej.1557.n6.nabble.com/Library-txt-is-not-being-loaded-td4999246.html

and was told the same. At the time I tried to use that name but didn't fix it.
Comment 3 Carnë Draug 2012-10-12 02:09:03 CDT
Hi

I can confirm that this bug is exclusive to FIJI. I have just download ImageJ on its own (1.47d), and Library.txt is loaded just fine. On this version of ImageJ I tried to rename Library.txt to FunctionLibrary.txt which made it fail so indeed Library.txt is the right name.

I have also tried to use FIJI with ImageJ 1.47d (not ImageJA) but that also does not fix the bug. This further suggests that the bug is somewhere in the FIJI project.

Carnë
Comment 4 Chris 2015-03-24 19:26:38 CDT
This bug severely limits the usefulness of macro scripting.  

I am certain that being able to maintain a reusable set of macro functions would make life a lot easy for many users.

Chris
Comment 5 Curtis Rueden 2015-03-24 21:41:52 CDT
I cannot reproduce this problem with an up-to-date Fiji on OS X 10.10.

I created the file /Applications/Fiji.app/macros/Library.txt and put the following contents:

 function hello() {
   showMessage("Hello world", "How's it going today?");
 }

I then started Fiji, pressed [ for the Script Editor, changed the Language to IJ1 Macro, and typed the following macro:

 hello();

Pressed Cmd+R to run, and it displayed the dialog as desired.

Can you please provide a more specific recipe to reproduce?
Comment 6 Chris 2015-03-25 00:45:48 CDT
Hi Curtis,

thanks for the quick the reply.

After playing around I think the problem is that I need to update the loaded macros after any changes are made to the Library.txt file.  I’ve found that “Help > Refresh Menus” does the trick.  

It seems that this can't be called from a macro, probably for good reasons.  Is there way to avoid manual refreshing?  

What I want to do is for my macro to update the helper functions by cat’ing all the *.ijm files some directory to Library.txt, refresh the macro list, then be able to user the function from Library.txt.  

Thanks,

Chris
Comment 7 Curtis Rueden 2015-04-06 17:19:42 CDT
I am closing this bug, since the description is "Library.txt is not being loaded" and it seems that it is now, in fact, being loaded as expected. A step forward. ;-)

Chris wrote:
> It seems that this can't be called from a macro, probably for good reasons.
> Is there way to avoid manual refreshing?  

Well, I think it can be called from a macro. It just shows that popup dialog box now. We added that on purpose so that people are aware that "Refresh Menus" doesn't do a complete job of actually refreshing the menus anymore. But perhaps we should not show that message in macro mode...

Chris wrote:
> What I want to do is for my macro to update the helper functions by
> cat’ing all the *.ijm files some directory to Library.txt, refresh
> the macro list, then be able to user the function from Library.txt.  

I'd like to understand your use case. Do you require this sort of dynamic updating without restarting ImageJ? Or would it be enough for your Library.txt to use a trick similar to:

https://github.com/fiji/fiji/blob/86622adda86e786dac01e8f7339cba5cb772b50b/macros/StartupMacros.fiji.ijm#L49-L60

?
Comment 8 Carnë Draug 2015-04-07 07:41:11 CDT
Curtis Rueden wrote on comment #7
> I am closing this bug, since the description is "Library.txt is not being loaded" and it seems that it is now, in fact, being loaded as expected. A step forward. ;-)

Yes, I confirm I can no longer reproduce this bug with latest update of FIJI. Thank you