如何在imacros中循环数组
How do I loop an array in imacros?
我想循环"pin_board",并在每次循环时替换"boardarray"。。这是下面的代码。``
var boardarray = ['board1', 'board2', 'board3', 'board4', 'board5'];
var text = 'pin_board';
for(var i in boardarray) {
pin_board = "CODE:";
pin_board += "VERSION BUILD=8300326 RECORDER=FX" + "'n";
pin_board += "TAB T=1" + "'n";
pin_board += "TAG POS=1 TYPE=BUTTON ATTR=TXT:Pin<SP>it" + "'n";
pin_board += "WAIT SECONDS=3" + "'n";
pin_board += "TAG POS=1 TYPE=LI ATTR=TXT:" + boardarray + "'n";
pin_board += "WAIT SECONDS=3" + "'n";
pin_board += "TAG POS=R1 TYPE=BUTTON ATTR=TXT:Pin<SP>it" + "'n";
pin_board += "WAIT SECONDS=5" + "'n";
}
iimPlay(pin_board);
感谢回复@karaxuna。。我修改了我的脚本,并在imacros上试用了它。。不幸的是,它只循环一次,而不是从board1开始,而是在baord5开始和结束。所以它只运行一次。我不知道我是否错过了什么。
这是经过编辑的代码。。
var boardarray = ['board1', 'board2', 'board3', 'board4', 'board5'];
var text = 'pin_board';
for(var i = 0; i < boardarray.length; i++)
{
pin_board = "CODE:";
pin_board += "VERSION BUILD=8300326 RECORDER=FX" + "'n";
pin_board += "TAB T=1" + "'n";
pin_board += "TAG POS=1 TYPE=BUTTON ATTR=TXT:Pin<SP>it" + "'n";
pin_board += "WAIT SECONDS=3" + "'n";
pin_board += "TAG POS=1 TYPE=LI ATTR=TXT:" + boardarray[i] + "'n";
pin_board += "WAIT SECONDS=3" + "'n";
pin_board += "TAG POS=R1 TYPE=BUTTON ATTR=TXT:Pin<SP>it" + "'n";
pin_board += "WAIT SECONDS=5" + "'n";
}
iimPlay(pin_board);
谢谢,
for(var i = 0; i < boardarray.length; i++)
{
//...
pin_board += "TAG POS=1 TYPE=LI ATTR=TXT:" + boardarray[i] + "'n";
}
不要将for in
用于数组,将其用于对象以列出其属性
编辑
var boardarray = ['board1', 'board2', 'board3', 'board4', 'board5'];
var pin_board = '';
for(var i = 0; i < boardarray.length; i++)
{
pin_board += "CODE:";
pin_board += "VERSION BUILD=8300326 RECORDER=FX" + "'n";
pin_board += "TAB T=1" + "'n";
pin_board += "TAG POS=1 TYPE=BUTTON ATTR=TXT:Pin<SP>it" + "'n";
pin_board += "WAIT SECONDS=3" + "'n";
pin_board += "TAG POS=1 TYPE=LI ATTR=TXT:" + boardarray[i] + "'n";
pin_board += "WAIT SECONDS=3" + "'n";
pin_board += "TAG POS=R1 TYPE=BUTTON ATTR=TXT:Pin<SP>it" + "'n";
pin_board += "WAIT SECONDS=5" + "'n";
}
"…不幸的是,它只循环一次,而不是从board1开始,而是在baord5开始和结束。所以它只运行一次。我不知道我是否错过了什么。"
当然,因为for
完成了工作,然后运行iimPlay(pin_board);
如果你想每次都运行-只需将iimPlay(pin_board);
放在for
中
for(var i = 0; i < boardarray.length; i++)
{
pin_board += "CODE:";
pin_board += "VERSION BUILD=8300326 RECORDER=FX" + "'n";
pin_board += "TAB T=1" + "'n";
pin_board += "TAG POS=1 TYPE=BUTTON ATTR=TXT:Pin<SP>it" + "'n";
pin_board += "WAIT SECONDS=3" + "'n";
pin_board += "TAG POS=1 TYPE=LI ATTR=TXT:" + boardarray[i] + "'n";
pin_board += "WAIT SECONDS=3" + "'n";
pin_board += "TAG POS=R1 TYPE=BUTTON ATTR=TXT:Pin<SP>it" + "'n";
pin_board += "WAIT SECONDS=5" + "'n";
iimPlay(pin_board);
}
你们读wiki.imacros.net吗?
var boardarray = ['board1', 'board2', 'board3', 'board4', 'board5'];
var pin_board = '';
for(var i = 0; i < boardarray.length; i++)
{
pin_board += "CODE:";
pin_board += "VERSION BUILD=8300326 RECORDER=FX" + "'n";
pin_board += "TAB T=1" + "'n";
pin_board += "TAG POS=1 TYPE=BUTTON ATTR=TXT:Pin<SP>it" + "'n";
pin_board += "WAIT SECONDS=3" + "'n";
pin_board += "TAG POS=1 TYPE=LI ATTR=TXT:{{board}}" + + "'n";
pin_board += "WAIT SECONDS=3" + "'n";
pin_board += "TAG POS=R1 TYPE=BUTTON ATTR=TXT:Pin<SP>it" + "'n";
pin_board += "WAIT SECONDS=5" + "'n";
iimSet("board", boardarray[i])
iimPlay(pin_board);
}
http://wiki.imacros.net/iimSet
相关文章:
- 如何将angularjs中的javascript字符串输出为循环数组
- 如何从某个位置顺时针和逆时针循环数组
- 赢得't循环数组javascript
- 通过循环数组内容
- 使用RegExp循环数组而不是for循环(Javascript)
- 如何在背景图像的循环数组中预加载图像
- 如何在循环数组内部推送变量值
- Javascript循环数组无限不起作用
- 如何循环数组
- 如何使用Handlebars循环数组对象和模板
- PHP同时循环数组数据显示到javascript中
- 如何使用上一个/下一个功能循环数组中的图像
- 如何循环数组并保持它们之间的索引增长
- Javascript循环数组以查找可被3整除的数字
- 以变量作为属性的循环数组
- 嵌套的“for”循环 - 数组未定义
- 在具有主干和车把的模型中循环数组
- 数组在 for 循环与第二个 for 循环数组 JavaScript 合并
- 对于javascript和jquery的循环数组问题
- 在循环数组 javascript 后替换对象属性值中的字符串