Search code examples
javascriptimacros

How to Stop iMacros JavaScript script?


Each time I use loops inside iMacros script the script will not stop when I press Stop button. It just skips to another loop counter and continues.

So if I have one macro inside two loops like bellow:

while(counter < 10)
{    
    for(var i=0; i<10; i++)
    {
        iimPlay(macro)
    }    
}

I would have to press Stop couple of times until some error doesn't pop out or the counters don't stop. So how to avoid this and when I press Stop button once the script stops?


Solution

  • add this:

    main:{
    while(counter<10)
    {
    for(var i=0;i<10;i++)
    {
    var ret=iimPlay(macro);
    if (ret == -101){break main;} // abort script if user presses Stop button
    }
    }
    }