Login  Register

Re: Check if command is finished in a macro

Posted by Djoere Gaublomme on Jun 05, 2015; 4:07pm
URL: http://imagej.273.s1.nabble.com/Check-if-command-is-finished-in-a-macro-tp5013045p5013052.html

Hi Mark,

Thank you for your answer.

I am afraid I am going to need some handholding, as I am unfamiliar  
with IJ methods.
Is this usable in a normal ImageJ macro?  Or only in a plugin?

When I try to run it in a macro, I get the error "Unrecognized IJ  
function name".
Is there a need to somehow import this method?

Kind regards

Djoere

PS: I assume there should be an extra parenthesis? --> while  
(IJ.macroRunning()) {



Quoting Mark Hiner <[hidden email]>:

> Hi Djoere,
>
>> I was wondering if it is possible to check whether a function has
> finished in a macro, in order to avoid the next command being initiated too
> early.
>
> I believe this is the purpose of the IJ.macroRunning[1] method.
>
> Instead of using wait(100), your while loop would look like this:
>
> while (IJ.macroRunning() {
> // Nothing needed here. Just wait for macro to end.
> }
>
> Hope that helps.
>
> Best,
> Mark
>
> [1]
> https://github.com/imagej/ImageJA/blob/v1.49t/src/main/java/ij/IJ.java#L348-L350
>
> On Fri, Jun 5, 2015 at 6:40 AM, Djoere Gaublomme <[hidden email]>
> wrote:
>
>> Hi all,
>>
>> I was wondering if it is possible to check whether a function has finished
>> in a macro, in order to avoid the next command being initiated too early.
>>
>> I have read the following:
>> http://imagej.1557.x6.nabble.com/Is-it-normal-to-use-a-wait-instruction-after-a-command-td5011551.html
>> , and applied the proposed solution therein for functions that produce a
>> new image window as output.
>> For example:
>>
>> while (!isOpen("Resulting-Image")) {
>> wait(100);
>> }
>>
>> However, I would also like to be able to check if filters that don't
>> produce a new image window, such as the "Gaussian Blur 3D", were executed
>> completely.
>>
>> Is there a trick that allows you to do this?
>> Or is it necessary to change the plugin to allow for this?  Would that be
>> a hard thing to do (I am only familiar with macros)?
>>
>> Thanks in advance for any ideas!
>>
>> Djoere
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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