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.
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
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

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

Post by chivracq » Mon Oct 09, 2017 8: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)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