how to loop from certain line of script

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

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
green.pine
Posts: 62
Joined: Thu Nov 04, 2010 5:21 pm

how to loop from certain line of script

Post by green.pine » Fri Sep 29, 2017 11:42 am

Hi;
running FF 55.0.3 on Win 7 32 bit, imacros ver. v8.9.7

I did use the script on this thread with the help of chivracq
http://forum.imacros.net/viewtopic.php? ... ail#p70484

but I want to do little more on this, and struggle to make it work,
I want the script skip one or few lines of script and continue.
but I could not figure it out how to do it with imacros, I am not sure if this can be done with imacros coding.
found some js loop script on this site, none I could use for this.

I don't think it is needed to paste the script from the link above, because I need only make the loop thing works.
this is what I want to do:

1- TAB 1- go to google and do a search
2- extract the content of the first page results, and click to the next page of the result
3- TAB 2 ,go to second url e.g. xyz.com
4- paste the data in there, extract new data
5- save the new data to a file
6- go back to line 2( which is On TAB 1, the second page of google result)


and continues to line 5, and then again from line 2.
so it is a loop, only the first time it starts at line 1, the second time and further starts from line 2 until the number of loops ends

I need it to set a number of loops as well, I don't want to do the loop unlimited.

appreciate any help on this.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: how to loop from certain line of script

Post by chivracq » Fri Sep 29, 2017 1:37 pm

green.pine wrote:Hi;
running

Code: Select all

FF 55.0.3 on Win 7 32 bit, imacros ver. v8.9.7
I did use the script on this thread with the help of chivracq
http://forum.imacros.net/viewtopic.php? ... ail#p70484

but I want to do little more on this, and struggle to make it work,
I want the script skip one or few lines of script and continue.
but I could not figure it out how to do it with imacros, I am not sure if this can be done with imacros coding.
found some js loop script on this site, none I could use for this.

I don't think it is needed to paste the script from the link above, because I need only make the loop thing works.
this is what I want to do:

1- TAB 1- go to google and do a search
2- extract the content of the first page results, and click to the next page of the result
3- TAB 2 ,go to second url e.g. xyz.com
4- paste the data in there, extract new data
5- save the new data to a file
6- go back to line 2( which is On TAB 1, the second page of google result)


and continues to line 5, and then again from line 2.
so it is a loop, only the first time it starts at line 1, the second time and further starts from line 2 until the number of loops ends

I need it to set a number of loops as well, I don't want to do the loop unlimited.

appreciate any help on this.
Yep, "Standard" way to achieve what you want would be to use indeed a '.js' Script, but it can as well easily be done in pure '.iim'.
What you want for 'Step_1' is a "Conditional Load of the Page" (+ "Conditional Search")) based on '!LOOP'.

If you want to code it in pure '.iim', search the Forum (my Posts mainly I think) on "Conditional" (+ "EVAL") + one of the following Keywords: "REFRESH" / "Reload" / "URL GOTO" and you'll find Threads where I've explained the "Technique", Threads related to "Nested Loop(s)" would be relevant as well...
And you would apply the same Technique to the 'TAG POS=n' for the 'TAG' Statements on the HTML Elements related to the Search as they would be present on the Google Page to "mute" them with a "TAG POS=0" (which won't do anything...!) after the 1st Run of the Loop, together with '!ERRORIGNORE' of course, and a short '!TIMEOUT_STEP' (=1 or 0), and you can even make the '!TIMEOUT_STEP' "Conditional" if you want, using the same Principle.
I use this Technique (about the Conditional '!TIMEOUT_STEP') indeed myself in a few of my Scripts, to strive for more "Reliability" in some parts of the Script where I know that some HTML Elements that need to be clicked should be there and other parts can run quicker especially if the Elements are not there...

More Info in the following Thread where I've probably already linked to a few relevant Threads for your Scenario as I maintain (sometimes...!) a List of interesting/useful/relevant Threads...:
- Workarounds for Conditional Logic in Macro Code
.
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Post Reply