0

I am able to read the data one by one in a loop but i want to get all of the data into an array. the below code is what i am using to get text file content into an array one by one.

    var linkurl; 
    linkurl =  "CODE:";
    linkurl +=  "SET !DATASOURCE C:\\Users\\InsaneRydr\\Documents\\iMacros\\Downloads\\link-realtor-profile.csv" + "\n";
    linkurl +=  "SET !DATASOURCE_LINE {{ee}}" + "\n";
    linkurl +=  "SET !EXTRACT {{!COL1}}" + "\n";  

for (var ee =1; ee<=100000000; ee++)
{
ret = iimSet("ee", ee);
 retcode = iimPlay(linkurl)
 var s = iimGetLastExtract(1);
if(retcode<0){
          break;
          }
          else {          
    listy.push(s);
}
}

But i want to get all of the data from text file into an array in a single run not by looping each line.

  • You cannot pass iMacros variables to javascript. You can pass javascript vars to iMacros, however. Take a look at this question and its answer: https://stackoverflow.com/questions/22031719/read-csv-file-with-javascript-into-a-key-value-pair-array - just an example, you should be able to find more/others/better. If I were you I would read the file with javascript, have my array, and then pass the variable or variables to iMacros – flish Jun 06 '17 at 10:29
  • @flish How do you get the data of a text file containing multiple lines into an array via javascript instead of imacros. This would be great help if you can teach me. – Piyush Verma Jun 06 '17 at 18:14
  • A lot depends on the structure of your file. Take a look at [my script](https://stackoverflow.com/questions/39809636/exclude-urls-when-running-a-script/39868461#39868461). There `var excLinks` is an array with the values from a text file. – Shugar Jun 07 '17 at 12:42

0 Answers0