[need help]Javascript and Imacros arrays question

walandio

Supreme Member
Joined
Jun 27, 2008
Messages
1,381
Reaction score
765
Hey there,

I am not really a coder, but I want to create an imacros using javascript. I would like to know how to loop an array in imacros.
What I want is to loop an Imacro function and choose different array everytime it loops.

Here is the code that I would like to create. This code works without error. But it doesn't work the way i want it. This code only choose the last array and doesn't even loop.

Code:
var warray = ['apple', 'banana', 'orange'];

var text = 'walandio';

for(var i = 0; i < warray.length; i++)
{
walandio = "CODE:";
walandio += "VERSION BUILD=8300326 RECORDER=FX" + "\n";
walandio += "TAB T=1" + "\n";
walandio += "TAG POS=1 TYPE=BUTTON ATTR=TXT:enter" + "\n";
walandio += "WAIT SECONDS=3" + "\n";
walandio += "TAG POS=1 TYPE=LI ATTR=TXT:" + warray[i] + "\n";
walandio += "WAIT SECONDS=3" + "\n";
walandio += "TAG POS=R1 TYPE=BUTTON ATTR=TXT:enter" + "\n";
walandio += "WAIT SECONDS=5" + "\n";
	
}
iimPlay(walandio);

I hope someone can help me make this thing work..

thanks,
 
wew.. thanks so much man..

it works..
 
wew.. thanks so much man..

it works..

I know ;) Because the error was a logical error.

What you were doing in the codes was, inside the loop, first you set the variable with details with the first array item, then change it again with the second, then the third again, and then as the loop finishes, it is being played.

To play all of them, you want to play as they the variables are set with details. i.e inside the loop. So it is played 3 times. Not just one time with the last array item.
 
very well explained man your such an awesome coder..
 
Back
Top