[bug] javascript "while (true)" breaks "stop" button

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
sourceofinfinity
Posts: 1
Joined: Fri Mar 27, 2009 12:53 pm

[bug] javascript "while (true)" breaks "stop" button

Post by sourceofinfinity » Sun Mar 29, 2009 7:46 pm

[edit: forgot to put my FF/OS/iMacro info :P]

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8
Windows XP, Home Edition
iMacro 6.2.1.4

This causes the stop button to break. The loop will run until you terminate the Firefox process. (Firefox will continue to run in the background if you just hit the close button).

Code: Select all

x = true;
while(x==true){
iimPlay("CODE:WAIT SECONDS=5");
}
kylehase
Posts: 1
Joined: Mon Jun 01, 2009 8:33 am

Re: [bug] javascript "while (true)" breaks "stop" button

Post by kylehase » Mon Jun 01, 2009 8:43 am

It seems the "stop" button only stops the iMacros script that's running inside the Javascript loop. Once the IMacros script stops, Javascript sees that it's done then continues to run it's loop. If you can figure out a way to break the loop I'd be very interested.

I tried to insert UI into the DOM with a button to set x=false but iMacros doesn't understand the document object.
leo
Posts: 3
Joined: Mon Jun 15, 2009 7:30 am

Re: [bug] javascript "while (true)" breaks "stop" button

Post by leo » Mon Jun 15, 2009 9:08 am

Any idea on how to forcefully stop a Javascript loop without having to kill the FireFox process?
dooferorg
Posts: 3
Joined: Tue Jun 22, 2010 5:37 pm

Re: [bug] javascript "while (true)" breaks "stop" button

Post by dooferorg » Tue Jun 22, 2010 5:40 pm

I would also like to know a workaround to this problem. Any word from the developers on this?

Clicking the stop button while in a macro of 'WAIT SECONDS=xxx' yields a return code of 1, and not -101 as mentioned by the documentation.
sotirisd
Posts: 48
Joined: Thu Mar 10, 2011 8:17 pm

Re: [bug] javascript "while (true)" breaks "stop" button

Post by sotirisd » Fri May 27, 2011 3:21 pm

The topic is old but the restore because it has given an answer.

I have exactly the same problem! and really is a serious problem! if you do something wrong in your code and put the javascript make endless loop, then we are trapped(gave the rest to) ...
or when you want to do some tests to see if something works ... have to wait to finish the whole loop ... else the javascript will not end!

So please someone answer this:
Any idea on how to forcefully stop a Javascript loop without having to kill the FireFox process?
thx!
MattBell7
Posts: 627
Joined: Thu Nov 26, 2009 11:07 am
Location: United Kingdom

Re: [bug] javascript "while (true)" breaks "stop" button

Post by MattBell7 » Fri May 27, 2011 3:38 pm

add in something like:

var err = iimGetLastError();
if (err == -101) {
x=false;
}

that way when you hit stop, the script will set the value to false (you could also just use 'break;'), and break you out of the loop.
sotirisd
Posts: 48
Joined: Thu Mar 10, 2011 8:17 pm

Re: [bug] javascript "while (true)" breaks "stop" button

Post by sotirisd » Fri May 27, 2011 3:55 pm

thank you, i try it!
sotirisd
Posts: 48
Joined: Thu Mar 10, 2011 8:17 pm

Re: [bug] javascript "while (true)" breaks "stop" button

Post by sotirisd » Mon Jun 06, 2011 8:32 am

MattBell7 wrote:add in something like:

var err = iimGetLastError();
if (err == -101) {
x=false;
}

that way when you hit stop, the script will set the value to false (you could also just use 'break;'), and break you out of the loop.
you have a wrong here...

iimGetLastError() return a message, that explain what happened...

the function: iimPlay() return the codes...

Code: Select all

var p = iimPlay(MacroCode);

if (p == -101) x=false;
MattBell7
Posts: 627
Joined: Thu Nov 26, 2009 11:07 am
Location: United Kingdom

Re: [bug] javascript "while (true)" breaks "stop" button

Post by MattBell7 » Mon Jun 06, 2011 4:12 pm

gah, was half asleep that day, you're correct, thats what i meant to write, interrogate the last error code, not the error text.

glad you got to the solution in the end :)
sotirisd
Posts: 48
Joined: Thu Mar 10, 2011 8:17 pm

Re: [bug] javascript "while (true)" breaks "stop" button

Post by sotirisd » Mon Jun 06, 2011 5:04 pm

MattBell7 wrote:
glad you got to the solution in the end :)
yes, but with your help... i don't know that when i click in the stop buttom imacro return -101 :wink:
Post Reply