Can I SET a MAX # of times to loop using code?

Discussions and Tech Support specific to the iMacros Firefox add-on.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
sweetrevelation
Posts: 29
Joined: Sat Feb 14, 2009 9:53 pm

Can I SET a MAX # of times to loop using code?

Post by sweetrevelation » Thu Mar 12, 2009 6:54 pm

I know I can set the
Play(Loop) to repeat the macro up to the maximum loop number specified. Note that you can set the !LOOP variable inside the macro, so it does not need to start at 1.
Is there a way to set the MAX: ?

I'd like to prompt the user to set the maximum times to loop.

I use SET !LOOP 1 to set the Current starting position of the loop.

Is there something like:

SET !LOOP MAX=5 or something to that effect?

I'm basically trying to prompt the user twice to set a range - from 1 - 10 loops for example. 1. to set the start of the loop, 2. to set the stop of the loop.
Marcia, Tech Support
Posts: 1095
Joined: Thu Jan 29, 2009 1:10 pm

Re: Can I SET a MAX # of times to loop using code?

Post by Marcia, Tech Support » Fri Mar 13, 2009 6:41 pm

Hello,
...SET !LOOP MAX=5 or something to that effect?
In the PRO version you can do it on the command line using the -loop switch.

In iMacros for Firefox you can write a javascript loop, and call iMacros with iimPlay inside it. Use javascript to prompt the user to set the upper bound for the loop.

With the scripting interface you can do this and much more :).
Regards,

Marcia
Nthn
Posts: 1
Joined: Mon Oct 19, 2015 7:36 am

Re: Can I SET a MAX # of times to loop using code?

Post by Nthn » Mon Oct 19, 2015 7:54 am

you could force imacros to stop with an error if it reaches a specific loop.

this code will stop the macro as soon as mLoop is reached, place it at the bottom of your code to complete the last loop, place it on top of your code to stop before starting the last loop

Code: Select all

SET VAR1 EVAL("var mLoop=20; if(parseInt(\"{{!LOOP}}\") >= mLoop){MacroError(\"Max Loop Reached \");}")
explanation of the code:
-then the maxLoop variable is set inside the EVAL
-the variable is compared with the current loop, if the current loop is the maximum loop (or greater, for example with the SET !LOOP command), then imacros stops with a costumisable errormessage
Post Reply