Hi Thomas,
as far as I can say you can't have global variables across different macro files, only within one macro file.
The way out would be using the ImageJ Preferences to store these values (as long as they are not arrays):
write:
call("ij.Prefs.set", "myMacros.myValue",toString(myVariable));
read (with default 999)
var myVariable = parseInt(call("ij.Prefs.get", "myMacros.myValue","999"));
Obviously, you don't need the 'toString' and 'parseInt' for Strings, and you should use parseFloat instead parseInt if you don't expect integers.
Michael
________________________________________________________________
On Apr 5, 2012, at 19:41, Thomas Binder wrote:
> Hello
>
> I have been trying for a log time to get global variables work in a macro
>
> There is a recommendation to define the variables in "StartupMacros.txt", after that they may be available.
>
> But if I try to print the variable
>
> <pencilWidth>
>
> which is defined in the default StartupMacro.txt after fresh installation of ImageJ
>
> ( var pencilWidth=1, eraserWidth=10, leftClick=16, alt=8; )
>
> after fresh startup of ImageJ
>
> I get an error message:
> -----------------------------------------------
> Undefined variable in line ...
> print ( <pencilWidth> );
> -----------------------------------------------
>
> Why ?
>
> Please help
>
> Thomas Binder