calling a macro within another macro

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

calling a macro within another macro

Agustin Lobo
I've created a macro that applies a set of processes to an image and now want
to apply this macro to a set of images within a loop. For this I have to
make a list and pass the name of each image to
the macro. No problem with the loop and with the list, but
have problems at actually passing the name as an argument.

To make a simpler example on how to run a macro using
variable arguments, I've done the following:
var s = "a string";
macro "Hola" {
//s = getString("Enter a String:", s);
print(s);
}
run("Hola","s= "+"Hola1");

My idea was that, after saving as "Holas.ijm" and  Ctrl-I, I could
just select and run
with Ctrl-Shift-R from within the editor
run("Hola","s= "+"Hola1");

and I would get "Hola1" in the Log window.
Nevertheless, I get "a string"

what am I doing wrong? why is my s argument in the call being ignored?

Thanks

Agus

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: calling a macro within another macro

Jean-Philippe Grossier
Hi,

I think you should use :
runMacro(macroName)
and getArgument()

for your example something like this:

s=getArgument();
//s = getString("Enter a String:", s);
print(s);

you save his as "Hola.ijm" in the macro folder

and from another macro:
runMacro("Hola", "hola1");

this works for me.

cheers,

jean-philippe grossier


2013/4/17 Agustin Lobo <[hidden email]>

> I've created a macro that applies a set of processes to an image and now
> want
> to apply this macro to a set of images within a loop. For this I have to
> make a list and pass the name of each image to
> the macro. No problem with the loop and with the list, but
> have problems at actually passing the name as an argument.
>
> To make a simpler example on how to run a macro using
> variable arguments, I've done the following:
> var s = "a string";
> macro "Hola" {
> //s = getString("Enter a String:", s);
> print(s);
> }
> run("Hola","s= "+"Hola1");
>
> My idea was that, after saving as "Holas.ijm" and  Ctrl-I, I could
> just select and run
> with Ctrl-Shift-R from within the editor
> run("Hola","s= "+"Hola1");
>
> and I would get "Hola1" in the Log window.
> Nevertheless, I get "a string"
>
> what am I doing wrong? why is my s argument in the call being ignored?
>
> Thanks
>
> Agus
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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