2015-08-15 62 views
0

我剛剛在Javascript中編寫了一個imacros腳本。該代碼在imacros中運行良好,但循環通過javascript運行時不會增加。以下代碼一直使用數據源csv文件的第一行。imacros javascript不會通過csv循環

macro += "VERSION BUILD=9002379" + "\n"; 
macro += "TAB T=1" + "\n"; 
macro += "TAB CLOSEALLOTHERS" + "\n"; 
macro += "SET !DATASOURCE C:\\imacros\\demo.csv" + "\n"; 
macro += "" + "\n"; 
macro += "SET !DATASOURCE_COLUMNS 3" + "\n"; 
macro += "SET !DATASOURCE_LINE {{!LOOP}}" + "\n"; 
macro += "URL GOTO={{!COL2}}" + "\n"; 
macro += "WAIT SECONDS=1" + "\n"; 
macro += "ADD !EXTRACT {{!COL1}}" + "\n"; 
macro += "" + "\n"; 
macro += "TAG POS=1 TYPE=DIV ATTR=CLASS:deguy EXTRACT=TXT" + "\n"; 
macro += "TAG POS=1 TYPE=DIV ATTR=ID:idvenga EXTRACT=TXT" + "\n"; 
macro += "SAVEAS TYPE=EXTRACT FOLDER=C:\\imacros FILE=results.csv" + "\n"; 
var n = 10; 

for (i=1;i<=n;i++){ 
iimPlay(macro); 
} 

我該如何通過數據源csv文件的所有行循環。

回答

0

這裏是一個不得不採取循環變量的控制什麼工作

macro += "VERSION BUILD=9002379" + "\n"; 
macro += "TAB T=1" + "\n"; 
macro += "TAB CLOSEALLOTHERS" + "\n"; 
macro += "SET !DATASOURCE C:\\imacros\\demo.csv" + "\n"; 
macro += "" + "\n"; 
macro += "SET !DATASOURCE_COLUMNS 3" + "\n"; 
macro += "SET !DATASOURCE_LINE {{i}}" + "\n"; 
macro += "URL GOTO={{!COL2}}" + "\n"; 
macro += "WAIT SECONDS=1" + "\n"; 
macro += "ADD !EXTRACT {{!COL1}}" + "\n"; 
macro += "" + "\n"; 
macro += "TAG POS=1 TYPE=DIV ATTR=CLASS:deguy EXTRACT=TXT" + "\n"; 
macro += "TAG POS=1 TYPE=DIV ATTR=ID:idvenga EXTRACT=TXT" + "\n"; 
macro += "SAVEAS TYPE=EXTRACT FOLDER=C:\\imacros FILE=results.csv" + "\n"; 


for (var i=1;i<10;i++) 
{ 

iimSet("i",i) 
iimPlay(macro) 
}