1

我想循环“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);

谢谢,

4

3 回答 3

1
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";
}
于 2013-07-01T07:40:11.740 回答
0

“......不幸的是,它只循环一次,而不是从 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);
}
于 2015-03-20T08:57:39.240 回答
-1

你们读过 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

于 2015-03-23T21:44:56.763 回答