If Statements inside While loop

Discussions and Tech Support specific to the iMacros Firefox add-on.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

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
Chillout1989
Posts: 22
Joined: Sat Oct 12, 2013 9:18 pm

If Statements inside While loop

Post by Chillout1989 » Tue Oct 22, 2013 7:41 pm

Hi,

i've got a problem regarding javascript and loops.

I've got a macro1 which clicks on a start button which exists x times. When it clicks on this button, a new tab is opened
Then i got another macro2 which clicks on another button on the new tab, then close the tab.
Then the start button which was clicked disappears, and the macro1 clicks the next one, until there is no button any longer.

The problem is, that there is not always a second button on the new opened page in tab2.
So if there is no Button in tab2, it should close the Tab directly and start macro1 again, searching for a new button in tab1.

I've made a while loop for clicking all the buttons in tab1, and when it doesnt find a button anymore it breaks the loop and move on with another macro.
I've tried to check in macro2 if the Button is on the second tab with IMAGESEARCH, and if it cant find that button it should close the tab, break the loop and move to macro1 again. Macro1 clicks the start Button again, then Macro2 plays and it checks again if there is this Button on the page. If yes, then click it, if not close tab and move to macro1 again.

Code: Select all

while(true)
	{
	var ret=iimPlay(start);
		while(true)
			{
				var ret2=iimPlay(check);
				if(ret2<0)
					{
					iimPlay("C:\\Users\\Karsten\\Documents\\iMacros\\Macros\\New_System\\tab_close");
					}
				{
				break;
				}
				
			}
		
	if(ret<0)
	{
	break;
	}
	}
What i'm doing wrong? I'm new at javascript and try to search the error myself for hours and hours.. But i can't find it


Edit: Ok problem solved by myself. This code works fine:

Code: Select all

while(true)
	{
	var ret=iimPlay(start);
	
	if (ret>0)
		 {
		var ret2=iimPlay(checklike);
			if (ret2<0)
				{
				iimPlay("C:\\Users\\Karsten\\Documents\\iMacros\\Macros\\New_System\\tab_close");
				}
		}

       else
                {
                break;
                }

	}
Post Reply