Calling a macro from a macro

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

Calling a macro from a macro

Gabriel Landini
Hi,
Is there a way from a macro to call another macro that uses the Dialog.*
functions in a similar way that plugin dialogs can be called/filled from a
macro?

I guess that one could use the getArgument() to parse a string passed from the
calling macro to the called one, but this implies that one has to write this
in every macro that one wants to be "callable" (sorry for the sloppy terms).

Thanks for any insights.
Regards,

Gabriel
Reply | Threaded
Open this post in threaded view
|

Re: Calling a macro from a macro

Albert Cardona
Gabriel,

The static ij.Macro.setOptions(String options) should be callable from a
macro using the call() macro function. If the String options contains
all the keys of the dialog fields, then the dialog should not show. I
have not tested it personally though, only from java plugins.

Albert

--
Albert Cardona
http://www.mcdb.ucla.edu/Research/Hartenstein/acardona
Reply | Threaded
Open this post in threaded view
|

Re: Calling a macro from a macro

Gabriel Landini
On Saturday 18 August 2007, Albert Cardona wrote:
> The static ij.Macro.setOptions(String options) should be callable from a
> macro using the call() macro function. If the String options contains
> all the keys of the dialog fields, then the dialog should not show. I
> have not tested it personally though, only from java plugins.

Thanks Albert,
The idea is great, but unfortunately it does not work so far:

The follwing macro (is this the way to implement what you suggested?):

//----------
call("ij.Macro.setOptions", "Sort=Aarea Order=Ascending Redirect=stones1.JPG
Background=Black");
run("Catalogue Particles");
//----------

calls the Catalogue_Particles macro but the dialog still shows as if it is run
on its own.

Regards,

Gabriel
Reply | Threaded
Open this post in threaded view
|

Re: Calling a macro from a macro

Albert Cardona
Gabriel,

I don't know where to find the Catalogue Particles plugin or what to use
it on to test,
but my first guess is that you need to use colons for the text fields
(and check that 'Aarea' doesn't have an extra letter 'a'):

//----------
call("ij.Macro.setOptions", "Sort='Aarea' Order='Ascending' Redirect='stones1.JPG'
Background='Black"');
run("Catalogue Particles");
//----------


Perhaps the colons are not necessary, but the "Aarea" looks like a
typing mistake, which would then flag the dialog to show.

Albert

--
Albert Cardona
http://www.mcdb.ucla.edu/Research/Hartenstein/acardona
Reply | Threaded
Open this post in threaded view
|

Re: Calling a macro from a macro

Gabriel Landini
On Sunday 19 August 2007 04:29:18 Albert Cardona wrote:
> I don't know where to find the Catalogue Particles plugin

In my hard disk! Sorry :-)

Wayne kindly looked into this problem and he reckons that if there is a run()
command before the dialog functions are executed, it resets the options.

I had a run("Select None"); before the Dialog.create() .
If I delete this, the dialog options are filled fine.

I thought that I would report this feature here so it gets recorded in the
archive for future reference.

Regards (and thanks Wayne!),

Gabriel