LOOP

Discussions and Tech Support related to the iMacros Firefox Add-on, including the built-in Javascript scripting interface for playing .js files.

Moderators: Community Moderators, iMacros Moderators

Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

Re: LOOP

by rouge02 on Sun Apr 03, 2011 5:38 am

Again looping the entire script is quite easy.. mainly interested in looping just a couple of specific lines within the script.
I just want to thank everyone for all their comments and advice on this topic.
I've leaned quite a lot since then and have refined most of my scripts to be a lot more efficient with the help I've gotten here,
and one of my co-workers. Still seeking to learn more about looping specific lines of script within the iMacro script itself,
so keep those comments coming in. Thanks
rouge02
 
Posts: 10
Joined: Mon Sep 28, 2009 10:45 am
Location: Trinidad and Tobago

Re: LOOP

by thankyou on Fri Aug 29, 2014 3:12 pm

xNeroX wrote:A neat trick to script a loop into the macro itself. use this
SET !LOOP -500
(This will trick the Macro into repeating 500 times)

Just REGISTER to say for you thank you,you made my day man :D best short answer. :D
thankyou
 
Posts: 1
Joined: Fri Aug 29, 2014 3:09 pm

Re: LOOP

by chivracq on Sat Aug 30, 2014 6:23 am

thankyou wrote:
xNeroX wrote:A neat trick to script a loop into the macro itself. use this
SET !LOOP -500
(This will trick the Macro into repeating 500 times)

Just REGISTER to say for you thank you,you made my day man :D best short answer. :D

This is brilliant indeed, I didn't know this Trick...! Thanks 'ThankYou' for bumping it, and thanks to 'xNeroX' as well of course for sharing the Trick...
(Tested on iMacros v8.8.2 for FF, Pale Moon v24.7.1 (=FF31), Win7-64.)

Another way that I use to have a Macro to loop itself is to have the Macro to call itself at the end of the Macro with 'URL GOTO', but you then enter an infinite Loop (that you have to stop at some point manually)... And another annoying drawback is that if you have the Macro running/looping in one FF Instance and you are doing something else in another FF Instance, the Macro will run at the next Loop in the exact Tab that has the Focus in the 2nd FF Instance...:
Code: Select all
URL GOTO=imacros://run/?m="Macro to loop.iim"
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6489
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: LOOP - be careful

by skippyto on Mon Sep 01, 2014 1:56 am

Hi,

Be careful with that kind of fast solution, this trick is useful only if you want your loop to be stopped if an error occurs while runnig your macros.
SET ERRORIGNORE YES is a way to continue on error but you won't know at the end if it happened or not...

As mentionned earlier in the thread, the best way to loop is to use a "for" or a "while" loop in a js.
You'll save a lot time on errror investigation as you can save macros return code (which is a good information) or/and play a second macro to take a screenshot when an error happen and/or replay the last loop if the error is a timeout or a loading page error...

Skippyto.
skippyto
 
Posts: 108
Joined: Wed Aug 20, 2008 1:14 am

Re: LOOP

by Cdangerdouglas on Mon May 22, 2017 1:47 pm

Hi @ABooth, would your code work if I wanted to loop a macro 200 times and then loop a separate macro100 ines?
Would I just replace the "i" variable with a new letter and reference a different .iim file? I am not too familiar with js. Any help is appreciated.
Cdangerdouglas
 
Posts: 1
Joined: Mon May 22, 2017 1:39 pm

Re: LOOP

by chivracq on Mon May 22, 2017 6:13 pm

Cdangerdouglas wrote:Hi @ABooth, would your code work if I wanted to loop a macro 200 times and then loop a separate macro100 ines?
Would I just replace the "i" variable with a new letter and reference a different .iim file? I am not too familiar with js. Any help is appreciated.

CIM...! :mrgreen:
Always mention your FCI when you open a Thread or post for the first time in some existing Thread, many Commands are not implemented in all Browsers/Versions... Especially 8 years later, ah-ah...!: Original Thread is from 2009, we are now in 2017...!

+ I see 3 Posts in this Thread from @ABooth on Page_1, all from 2009, quote which one or which Script you refer to, I would be (positively!) surprised if @ABooth replied directly...

Your Qt is a bit vague, be more precise... :idea:
=> Not sure what "a separate macro100 ines" means...? :?
=> Maybe interesting Threads for you if you search the Forum on "Nested Loops", but again, your Qt is not clear..., so I'm not sure if it's relevant for you...

[And to whomever created this Thread, you are "lucky" I was not around at that time, the Thread Title is a bit useless, "LOOP", ah-ah...! Try searching the Forum with "loop" as a Search Keyword...! But on the other hand, I think I saw some very interesting Posts in this Thread which probably never get found because of the useless Thread Title, @TechSup, maybe an idea to give this Thread a bit more Descriptive Thread Title...?]
But I'll read the Content of the Thread if previous Poster follows up a bit correctly...
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6489
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: LOOP - be careful

by chivracq on Mon May 22, 2017 6:35 pm

skippyto wrote:Hi,

Be careful with that kind of fast solution, this trick is useful only if you want your loop to be stopped if an error occurs while runnig your macros.
SET ERRORIGNORE YES is a way to continue on error but you won't know at the end if it happened or not...

As mentionned earlier in the thread, the best way to loop is to use a "for" or a "while" loop in a js.
You'll save a lot time on errror investigation as you can save macros return code (which is a good information) or/and play a second macro to take a screenshot when an error happen and/or replay the last loop if the error is a timeout or a loading page error...

Skippyto.

Hum sorry @skippyto, I never saw your Reply, I guess it was meant at me... (from my previous Reply)

Hum, I see the cleverness in "...and/or replay the last loop if the error is a timeout or a loading page error...", but hum, 3 years later, so I've come a little bit further with my "Techniques", ah-ah...!, I am able to that in pure '.iim', (and I check much more than only "timeout or a loading page error"), and still using this Trick (Negative Loop), many of my Macros decide dynamically by themselves how many times they need to run (I simply hit 'Play' and they know if they only need to run once or several times...) and from several Checkpoints in the middle if some extra Run(s) need(s) to run for the full Macro or only part(s) of it... And all that in pure '.iim'..., oops...! :oops:

But hum, I often have a very bad Internet Connection (surfing on some nice Neighbour's), only between 02h-06h at night I can trust that a Macro will run a bit correctly, so all my Macros are very "Error-resistant", in order to "guarantee" some "Reliability", ah-ah...!
Hum, and even then they are able to decide by themselves if they go for Reliability or for Speed, depending on "my" Connection and "other" Parameters... (+ heavy Logging and Reporting, for me to check if I need to modify some Threshold..., but they can even modify those Thresholds by themselves...)
But hum, that reminds me to have a look at some Macros of mine that run completely automatically and that I never (need to) check, I had noticed some mini-"Glitch" when the Summer/Winter Time/DST Change was taking place, ah-ah...! Even if I think the Pb/"Bug" was OS related (Task Scheduler on Win10-x64), (and solved only after a Reboot), but I could still "foresee" it and implement some Workaround from within the Macro(s) it/themself/ves to keep working correctly without the need for a quick Reboot asap after a DST Change...

Oh yeah...!, and that's one of the "main" Reasons as well why I "like" and use 'Negative Loop' a lot, as it offers a way to loop an '.iim' Macro (without the need for a '.js' Script) when launched from a '.BAT' File and/or from the OS Task Scheduler, ah-ah...! 8)
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6489
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Previous

Return to iMacros for Firefox

Who is online

Users browsing this forum: No registered users and 6 guests

-->