Issue when looping in js, is doing 1,2 and then 4, why?

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
frankhack1
Posts: 83
Joined: Fri Mar 20, 2009 9:12 pm

Issue when looping in js, is doing 1,2 and then 4, why?

Post by frankhack1 » Fri Mar 25, 2016 1:17 am

Hi.

First of all my info:
- Win7 x64
- Firefox PaleMoon 24.6.2 (x86)
- iMacros 8.8.2

Now the issue.
01. I have 2 js. The 1st macros calls the 2nd macros and this after that is executed, then the 1st macros do a loop and execute the 2nd macros again and so on.
02. The loop start at 1, then it goes to 2 but for some reason it goes to 4 instead of 3 and then it goes to 6 instead of 4 and so on.
03. The following examples are simplified macros, in fact the real macros are more than 900 lines of code, but this simplified macros also fail on the same place.
* Note: I need the 1st macros to call the 2nd macros, so if you can kindly do not suggest to do all the scripting on 1 macros. I really need one macros calling the other.

Content of 1st macros

Code: Select all

var start = 1;
var loop = 10;
// The code above says that I want the loop to start in 1 and end in 10.

// This is the macros calling other macros
var macros;
    macros =  "CODE:";

macros += "PROMPT {{loop}}" + "\n"; // <--- With this line I'm graphically reading the loop and here is where I see that is doing 1, then 2 but then 4 and then 6 and so on, it just continue jumping 2 numbers until it reach 10, but we need to loop 1,2,3,4,5,6,7,8,9,10

macros += "URL GOTO=imacros://run/?m=01_PISOS/Espana/Barcelona/01_Tablon_Anuncios/LoQUo/Creador/macros/test.js" + "\n";

for (i=start;i<loop;i++) {
iimSet("loop",i)

iimPlay(macros)

}

Content of 2nd macros (test.js)

Code: Select all

iimPlay("CODE: URL GOTO=google.com")
I did a video = https://youtu.be/3idPOKYJCXw
frankhack1
Posts: 83
Joined: Fri Mar 20, 2009 9:12 pm

Re: Issue when looping in js, is doing 1,2 and then 4, why?

Post by frankhack1 » Sat Mar 26, 2016 1:37 pm

Anyone? 2 days from this post.
Trax
Posts: 43
Joined: Thu Sep 13, 2012 4:07 pm
Contact:

Re: Issue when looping in js, is doing 1,2 and then 4, why?

Post by Trax » Sat Mar 26, 2016 2:05 pm

Works fine for me ..
frankhack1
Posts: 83
Joined: Fri Mar 20, 2009 9:12 pm

Re: Issue when looping in js, is doing 1,2 and then 4, why?

Post by frankhack1 » Sat Mar 26, 2016 3:03 pm

Hi.

In your Firefox is going 1, 2, 3, 4, 5, 6, 7, 8, 9, 10?

Did you saw my video, there you can see mine is going 1,2,4,6,8
frankhack1
Posts: 83
Joined: Fri Mar 20, 2009 9:12 pm

Re: Issue when looping in js, is doing 1,2 and then 4, why?

Post by frankhack1 » Mon Mar 28, 2016 1:07 am

chivraq, maybe you have an idea? I have the same configuration as you.
chivracq
Posts: 8980
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Issue when looping in js, is doing 1,2 and then 4, why?

Post by chivracq » Mon Mar 28, 2016 7:08 am

frankhack1 wrote:chivraq, maybe you have an idea? I have the same configuration as you.
Ah-ah...!, yep, sorry, I had seen your Thread, didn't really have any time to do any Digging into it, I was celebrating stg since Thursday..., until now, and I need some sleep, oops...!
I'll have a look..., try to include a Double 'PROMPT'/'alert()' to follow the 'Loop', there might be a Bug or it might be Legit and you'll have to find a Workaround to "fool" the Loop... (I know a few ways...)

Bump your Thread once you've seen my Reply, otherwise I may forget about it...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
frankhack1
Posts: 83
Joined: Fri Mar 20, 2009 9:12 pm

Re: Issue when looping in js, is doing 1,2 and then 4, why?

Post by frankhack1 » Thu Mar 31, 2016 6:43 pm

Hi chivracq

Check the "Content of 1st macros"
The problem is on the line 11, where the "test.js" is being called. If I remove or comment (//) that line, all works good but I do need the 1st macros to call the 2nd macros, I know I can put it all in one macros but I said, what you see here is not the real thing, the real macros is like 900 lines bigger. So if I can manage to make this small macros to work, the real macros will work as well.

What will be those workaround to fool the loop that you know?
chivracq
Posts: 8980
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Issue when looping in js, is doing 1,2 and then 4, why?

Post by chivracq » Sun Apr 03, 2016 11:43 pm

OK, my Thoughts about your Qt/Pb...

I don't use any '.js' Scripts, so I'm a bit of a Beginner on the Subject, I would think you are 20 times more advanced than me and I will be starting completely from scratch to find a Solution, provided I can reproduce your Pb...

So OK, I don't use any '.js' Scripts and I do all my Macros in pure '.iim', with very complex Conditional Behaviour and auto-deciding and auto-adapting and auto-morphing Macros that can qualify for IA... My Macros decide by themselves how many times they have to loop (or only run once), they learn from the last Run(s) if they have to modify stg in the Macro, they decide to stop in the middle or to continue if stg goes wrong or are able to start all over again, and I get some nice Reporting in the End. All that in pure '.iim'...
I understand that People use '.js' Scripts for Conditional Behaviour, perfect (well, that's the "Standard" way actually, oops...!), I find 'on the fly generated' '.iim' Macros already Cumbersome (that you use...) and a '.js' Script calling another one while stg is being looped Double Cumbersome..., so yep, "I would kindly suggest to do the (whole) Scripting differently", I don't have all Info to know exactly what you are doing so I can't come up with some other/better Solution...

So I don't know how to correct the Loop, (in your '.js' Script, I hardly know anything about JavaScript..., that's why I do all my Scripting in pure '.iim'..., oops...! :oops: ), my Workaround(s) would be, OK, you know the Loop goes 1/2/4/6/8/etc, then...
1- you can just correct it (and it's not clear to me if you need it in some '.iim' part to use it for fetching Data from a DataSource for example) using 'EVAL()' dynamically in your Macro in '.iim'
2- or in your '.js' Script,
3/4- or you split the Loop into 2 Loops, one for 1/2 or just 1 and the other one for 4/5/8/etc or 2/4/6/8/etc,
5- or you store it in some Temp '.TXT' File that will be "leading"...
(And there are probably other ways...)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
Post Reply