#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Location
    Canada
    Posts
    26
    Rep Power
    0

    JS nested loop in imacros not work the way it should


    Hello;
    I have been trying to make a nested loop work but somehow it does not work the way I want to .

    the js loop script is within imacros,
    it search google using keywords from csv, it is a for loop until the end of keyword,
    it extract and save the result data, from each page of result.

    it should click on next button,
    where there is no Next button, then it should continue to the next keyword and continues.
    but this macro click on the next button only 4 times, and goes to the next keyword.
    I have imacro 8.9.7, on Firefox 55, running windows 7 32.

    anyone can help me out, please?
    thanks;

    Edit: I noticed it clicks on Next button 3 times not 4 times.

    Here is my code, extracting and saving data is not included in the macro;

    Code:
    var macro;
    macro = "CODE:";
    macro +=  "SET !ERRORIGNORE YES" + "\n";
    macro +=  "SET !EXTRACT_TEST_POPUP NO" + "\n";
    macro +=  "SET !DATASOURCE keywords.csv" + "\n";
    macro +=  "SET !DATASOURCE_COLUMNS 1" + "\n";
    macro +=  "SET !LOOP 1" + "\n";
    macro +=  "SET !DATASOURCE_LINE {{RowNo}}" + "\n";
    
    macro +=  "URL GOTO=https://www.google.com/ncr" + "\n";
    macro +=  "TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT={{!COL1}}" + "\n";
    macro +=  "TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:tsf ATTR=NAME:btnK" + "\n";
    
    var NextBtnCheck=iimGetLastExtract();
    
    var NextButton;
    NextButton = "CODE:";
    NextButton +=  "SET !ERRORIGNORE YES" + "\n";
    NextButton +=  "SET !EXTRACT_TEST_POPUP NO" + "\n";
    NextButton +=  "TAB T=1" + "\n";
    
    NextButton +=  "WAIT SECONDS=1" + "\n";
    NextButton +=  "TAG POS=1 TYPE=A ATTR=TXT:Next" + "\n";
    NextButton +=  "WAIT SECONDS=0.5" + "\n";
    
    
    for(var m=1; m<30; m++)
    {iimSet("RowNo",m)
    iimPlay(macro)
    
    var n = 0
    var n= iimPlay(NextButton);
    
    	do
    		{
    		iimSet("n",n)
    		iimPlay(NextButton);
    		
    		if (NextBtnCheck !== "#EANF#");
    		break;
    		n++; 
    		} 
    		while(true)
    		{
    	   iimSet("n",n);
    		iimPlay(NextButton);
    		}
    }
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Location
    Canada
    Posts
    26
    Rep Power
    0
    I made it work, I got help from another forum, for some people who may have same issues, here is the code change in the nested loop:
    Code:
    var NextButton;
    NextButton = "CODE:";
     
    NextButton +=  "SET !EXTRACT_TEST_POPUP NO" + "\n";
    NextButton +=  "TAB T=1" + "\n";
    NextButton +=  "TAG POS=1 TYPE=A ATTR=TXT:Next" + "\n";
    
    
    var NextBtnCheck=iimGetLastExtract();
    
    
    for(var m=1; m<30; m++) {
        iimSet("RowNo",m)
        iimPlay(macro)
    
        do {
            var NextBtnCheck = iimPlay(NextButton);
            if (NextBtnCheck != 1)
                break;
        } while(true)
    	 
    }

IMN logo majestic logo threadwatch logo seochat tools logo