[need help]imacros javascript if else on for loop

Discussions and Tech Support specific to the iMacros Firefox add-on.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
chupstogo
Posts: 4
Joined: Tue Jul 02, 2013 5:49 am

[need help]imacros javascript if else on for loop

Post by chupstogo » Tue Jul 02, 2013 5:58 am

Hey there, I stumble a little problem in my code on imacros. I am creating an imacros that will loop an array but sometimes the given array isn't available and creates error. I don't want to use the !ERRORIGNORE command since it will click the enter button twice so I need the process to end and proceed to the next array.

My question is How do i create an if else statement inside the loop? if imacros can't find 'banana' it will stop the 'banana' process and then proceed to 'orange' or the next array?

Code: Select all

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);	
}
iimPlay(walandio);
thanks,
User avatar
FoxDot
Posts: 20
Joined: Thu Jun 13, 2013 2:31 pm
Location: Chisinau
Contact:

Re: [need help]imacros javascript if else on for loop

Post by FoxDot » Tue Jul 02, 2013 9:40 am

use iimGetLastError() after walandio += "TAG POS=1 TYPE=LI ATTR=TXT:" + warray + "\n";

Code: Select all

iimPlay(walandio); 
if(iimGetLastError()!='OK')
              continue;
                else
                     {
walandio = "WAIT SECONDS=3" + "\n";
walandio += "TAG POS=R1 TYPE=BUTTON ATTR=TXT:enter" + "\n";
walandio += "WAIT SECONDS=5" + "\n";

}
The Fox Will Find You!
Post Reply