Search code examples
javascriptimacros

iMacro skipping iimPlay in JS Loop


my imacro js code is here:

    var doi1 =  "CODE:";
    doi1 +=  "SET !DATASOURCE links.csv" + "\n";
    doi1 +=  "SET !DATASOURCE_COLUMNS 5" + "\n";
    doi1 +=  "SET !DATASOURCE_LINE {{l}}" + "\n";
    doi1 +=  "URL GOTO={{!COL1}}" + "\n";
    doi1 +=  "WAIT SECONDS = 3" + "\n";

var doi2 =  "CODE:";
    doi2 +=  "SET !DATASOURCE links.csv" + "\n";
    doi2 +=  "SET !DATASOURCE_COLUMNS 5" + "\n";
    doi2 +=  "SET !DATASOURCE_LINE {{l}}" + "\n";
    doi2 +=  "URL GOTO={{!COL2}}" + "\n";
    doi2 +=  "WAIT SECONDS = 3" + "\n";

for(l=1;l<5;l++){
    iimSet("l",l); 

    iimPlay(doi1);

    iimPlay(doi2);
}

when i'm run this only loop the column 1 urls, seems like imacro skip the 2nd iimPlay.

Why this? please help me.


Solution

  • Try to write the loop as follows:

    for(l = 1; l < 5; l++) {
        iimSet("l",l); 
        iimPlay(doi1);
    
        iimSet("l",l); 
        iimPlay(doi2);
    }