How to use EVAL to Stop the Macro when there is no Next?

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.

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: How to use EVAL to Stop the Macro when there is no Next?

by chivracq on Mon Oct 09, 2017 1:13 pm

green.pine wrote:thank you for your reply, and explanation;
I did a new try, but still can not do the anther loop, it seems that I have to change the whole coding to do that, I get confused, anyhow

this time I use it another way, which does not work properly;

Code: Select all
TAG POS=1 TYPE=A ATTR=ID:PNNEXT EXTRACT=TXT
TAG POS=1 TYPE=A ATTR=ID:PNNEXT
SET New_KW_Start EVAL("var s='{{!EXTRACT}}'; var x,y,z; if(s!=='next'){z=1;} else{z=0;}; z;")

TAG POS={{New_KW_Start}} TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT={{!COL1}}
TAG POS={{New_KW_Start}} TYPE=INPUT:SUBMIT FORM=ID:tsf ATTR=NAME:btnK
SET !TIMEOUT_STEP 1


this time it gets keyword from csv file, do the search and grab the text, and go to TAB2, do the task there,come back to TAB1, click the Next, but get new keyword from CSV file and do a search, it suppose to do the highlighting and copy the text.

It does not even go through all keywords in the csv file, only 5 keywords and stops, no errors,

somehow I have to change the value of Loop_Switch again, or redo the whole coding, which is too complicated for me.

Code: Select all
SET URL_GOTO EVAL("var n='{{!LOOP}}', u='{{URL_Search}}'; var x,y,z; if(n==1){z=u;} else{z='';}; z;")
URL GOTO={{URL_GOTO}}
TAG POS={{LOOP_Switch}} TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT={{!COL1}}
TAG POS={{LOOP_Switch}} TYPE=INPUT:SUBMIT FORM=ID:tsf ATTR=NAME:btnK
SET !TIMEOUT_STEP 1


appreciate your help again.
thanks

"it seems that I have to change the whole coding to do that..."
=> Well, yep a bit, ah-ah..! In JavaScript and any "proper" Programming Language you can usually reuse some existing Code and encapsulate it into some Object/Function/even Macro for iMacros to reuse it in some broader Context, but in pure '.iim' with 'EVAL()', you need to "plan" your "Strategy" thoroughly and carefully...
The original Topic of the Thread with the Info you had provided was "only" about stopping the Script if some Button/Link was not present anymore, the 2nd Level of Looping and Input from a DataSource came afterwards, it's "easier" for a "Global Strategy" if you provide all Info to get a "Global Overview" of your Scenario from the beginning...

But..., Okay, I mentioned "Nested Loops" already, but your Script still doesn't contain any "Nested Loop(s)" Ingredient in what you try...
A "simple" Search on "Nested Loops Modulo" returns quite a few related/similar Threads and the 1st one from the List is already completely similar to your Scenario I would think from a quick Reading...:
- How to use Conditional EVAL going to certain urls
=> Have a look at this Thread already and to understand the Principle and see if you can adapt/apply it to your Needs... The other User managed to write and get his whole Script working, then you can do it as well, ah-ah...! :wink:
- (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: 6485
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Previous

Return to General Support & Discussions

Who is online

Users browsing this forum: Bing [Bot] and 9 guests

-->