如何正确使用循环
How to correctly use loop
我有邀请朋友加入 FB 群组的宏,朋友的名字取自 CSV 文件,所以我需要编写循环,而不是从 csv 文件邀请所有人。这是我的宏
var macro,start;
macro = "CODE:";
macro += "SET !ERRORIGNORE YES" + "\n";
macro += "SET !EXTRACT_TEST_POPUP NO" + "\n";
macro += "SET !DATASOURCE FB<SP>Groups.csv" + "\n";
macro += "SET !DATASOURCE_COLUMNS 1000" + "\n";
macro += "SET !LOOP 1" + "\n";
macro += "SET !DATASOURCE_LINE {{!LOOP}}" + "\n";
macro += "URL GOTO=" + "\n";
macro += "TAG POS=1 TYPE=I ATTR=CLASS:" + "\n";
所以我认为必须从这里开始循环
macro += "TAG POS=2 TYPE=SPAN ATTR=TXT:Invite<SP>Friends" + "\n";
macro += "SET !DATASOURCE FB<SP>Users.csv" + "\n";
macro += "SET !DATASOURCE_COLUMNS 1000" + "\n";
macro += "SET !LOOP 1" + "\n";
macro += "SET !DATASOURCE_LINE {{!LOOP}}" + "\n";
macro += "TAG POS=1 TYPE=INPUT:TEXT ATTR=CLASS:" + "\n";
macro += "TAG POS=1 TYPE=SPAN ATTR=CLASS:uiButtonText" + "\n";
iimPlay(macro)
玩这个片段:
var macro = "CODE:";
for (i = 1; i <= 3; i++) {
macro += "SET !DATASOURCE FB<SP>Users.csv" + "\n";
macro += "SET !DATASOURCE_LINE " + i + "\n";
macro += "PROMPT {{!COL1}}" + "\n";
iimPlay(macro);
}
希望你能抓住思路。
这里是定义 csv 文件行数的方法:
var numRows = 0;
while (true) {
var macro = "SET !DATASOURCE FB<SP>Users.csv" + "\n";
macro += "SET !DATASOURCE_LINE " + (numRows + 1) + "\n";
if (iimPlayCode(macro) == 1)
numRows++;
else
break;
}
alert(numRows);
我有邀请朋友加入 FB 群组的宏,朋友的名字取自 CSV 文件,所以我需要编写循环,而不是从 csv 文件邀请所有人。这是我的宏
var macro,start;
macro = "CODE:";
macro += "SET !ERRORIGNORE YES" + "\n";
macro += "SET !EXTRACT_TEST_POPUP NO" + "\n";
macro += "SET !DATASOURCE FB<SP>Groups.csv" + "\n";
macro += "SET !DATASOURCE_COLUMNS 1000" + "\n";
macro += "SET !LOOP 1" + "\n";
macro += "SET !DATASOURCE_LINE {{!LOOP}}" + "\n";
macro += "URL GOTO=" + "\n";
macro += "TAG POS=1 TYPE=I ATTR=CLASS:" + "\n";
所以我认为必须从这里开始循环
macro += "TAG POS=2 TYPE=SPAN ATTR=TXT:Invite<SP>Friends" + "\n";
macro += "SET !DATASOURCE FB<SP>Users.csv" + "\n";
macro += "SET !DATASOURCE_COLUMNS 1000" + "\n";
macro += "SET !LOOP 1" + "\n";
macro += "SET !DATASOURCE_LINE {{!LOOP}}" + "\n";
macro += "TAG POS=1 TYPE=INPUT:TEXT ATTR=CLASS:" + "\n";
macro += "TAG POS=1 TYPE=SPAN ATTR=CLASS:uiButtonText" + "\n";
iimPlay(macro)
玩这个片段:
var macro = "CODE:";
for (i = 1; i <= 3; i++) {
macro += "SET !DATASOURCE FB<SP>Users.csv" + "\n";
macro += "SET !DATASOURCE_LINE " + i + "\n";
macro += "PROMPT {{!COL1}}" + "\n";
iimPlay(macro);
}
希望你能抓住思路。
这里是定义 csv 文件行数的方法:
var numRows = 0;
while (true) {
var macro = "SET !DATASOURCE FB<SP>Users.csv" + "\n";
macro += "SET !DATASOURCE_LINE " + (numRows + 1) + "\n";
if (iimPlayCode(macro) == 1)
numRows++;
else
break;
}
alert(numRows);