javascriptextractimacros

iMacro JavaScript Extracting values


I am trying to make objects in javascript using iMacros and I guess the easiest way to ask this is to show you want I got.

var load;
load = "CODE:";
load += "SET !DATASOURCE pinterestAccounts.csv" + "\n";
load += "SET !DATASOURCE_COLUMNS 4" + "\n";
load += "SET !LOOP 1" + "\n";
load += "SET !DATASOURCE_LINE {{!LOOP}}" + "\n"; 


var accounts = new Array();
for(i=0; i<5; i++){
    iimPlay(load);
    accounts[i] = new Account("{{!COL1}}","{{!COL2}}","{{!COL3}}","{{!COL4}}");
}

so I have a class Accounts which takes the 4 parameters and I an trying to extract them from a csv but I can not find out where to put the extract commands. I saw an example that gets the last extraced value but I want 4 values now, 5 later.

Think you could show me how to extract multiple values with Javascript?


Solution

  • I solved m own problem

    var load;
    load = "CODE:";
    load += "SET !DATASOURCE pinterestAccounts.csv" + "\n";
    load += "SET !DATASOURCE_COLUMNS 4" + "\n";
    load += "SET !LOOP "+ "{{index}}" + "\n";
    load += "SET !DATASOURCE_LINE {{!LOOP}}" + "\n"; 
    load += "ADD !EXTRACT {{!COL1}}" + "\n";
    load += "ADD !EXTRACT {{!COL2}}" + "\n";
    load += "ADD !EXTRACT {{!COL3}}" + "\n";
    load += "ADD !EXTRACT {{!COL4}}" + "\n";
    
    var accounts = new Array();
    for(i=1; i<=5; i++){ 
        iimSet("index",i);
        iimPlay(load);
        var un = iimGetLastExtract(1);
        var e = iimGetLastExtract(2);
        var pw = iimGetLastExtract(3);
        var pr = iimGetLastExtract(4);
        accounts[i] = new Account(e,un,pw,pr);
    }