如何正确使用循环 [英] How to correctly use loop
本文介绍了如何正确使用循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有邀请朋友加入FB组的宏,朋友名称是从CSV文件中提取的,所以我需要执行写循环,而不是从csv文件中邀请所有人.这是我的宏
I have macros that invites friends to FB groups, friends name is taken from CSV file, so i need write loop, than will invites all people from csv file . Here is my macros
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";
所以我认为从这里必须开始循环
So i think from here must starts loop
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);
}
希望,您可以理解这个主意.
Hope, you can catch the idea.
这是一种在csv文件中定义行数的方法:
Here is a way of how to define the number of rows in your csv-file:
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);
这篇关于如何正确使用循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文