Re: User-defined functions
Posted by
seb-7 on
URL: http://imagej.273.s1.nabble.com/User-defined-functions-tp3701916p3701920.html
Andy Weller wrote:
> Hi all,
>
> (I will document the response to this on the Docs website soon.)
>
> For some reason I can't set global variables outside my macro?! The
> macro just doesn't start.
Hi Andy,
If you use the macro editor and want to run it, try to install it first
(usually Ctl-I) and start it from the menu.
>
> What if I want to return 2 variables instead of just the 1 - or is this
> bad practise? (I guess I can call a function from within a function.)
>
> macro "test"
> {
> x, y=doit();
> print(x, y);
> }
>
> function doit()
> {
> x=10;
> y=20;
> return x, y;
> }
>
> ?!?
Your function can't return multiple values, but you can return an array:
function foobar()
{
output=newArray("foo","bar");
return output;
}
macro "test"
{
strarray=foobar();
print (strarray[0]+"\n"+strarray[1]);
}
Sebastien