Conditional EVAL going to certain urls

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

Conditional EVAL going to certain urls

by a2515125 on Wed Oct 10, 2018 2:22 am

FF52 / imacros 8.9.7 / windows 10/


I have similar problem like this previous post

last time I want to navigate to next url every 4950 loops, it did well thanks to chivracq :))

but this time I want to move next url by counting different variable loop which I put in !COL2

I put !COL1 as my urls and !COL2 as variable

I would like to my script to move next url after loop 2/ 3/ 1 / 17 times.....and so on
example:

after loops 2 time ....url move to A2
after loops 3 time ....url move to A3
after loops 1 time ....url move to A4
after loops 17 time ....url move to A5

but my !DATASOURCE_LINE is not 1 2 3 4 5 6

so please help to solve my SET !DATASOURCE_LINE.........Orz



Image

Code: Select all

SET !REPLAYSPEED FAST
SET !EXTRACT_TEST_POPUP NO
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0
SET !LOOP
SET !DATASOURCE 01_urls.csv
FILTER TYPE=IMAGES STATUS=ON

SET Reload_DataSource_Line EVAL("var x; y='{{!LOOP}}';w='{{!COL2}}'; if(y%w ==0); x=x++;")
PROMPT {{Reload_DataSource_Line}}
SET !DATASOURCE_LINE {{Reload_DataSource_Line}}

a2515125
 
Posts: 102
Joined: Mon Dec 05, 2016 8:37 pm

Re: Conditional EVAL going to certain urls

by chivracq on Wed Oct 10, 2018 5:03 am

a2515125 wrote:
Code: Select all
FF52 / imacros 8.9.7 / windows 10/


I have similar problem like this previous post

last time I want to navigate to next url every 4950 loops, it did well thanks to chivracq :))

but this time I want to move next url by counting different variable loop which I put in !COL2

I put !COL1 as my urls and !COL2 as variable

I would like to my script to move next url after loop 2/ 3/ 1 / 17 times.....and so on
example:

after loops 2 time ....url move to A2
after loops 3 time ....url move to A3
after loops 1 time ....url move to A4
after loops 17 time ....url move to A5

but my !DATASOURCE_LINE is not 1 2 3 4 5 6

so please help to solve my SET !DATASOURCE_LINE.........Orz

Image

Code: Select all
SET !REPLAYSPEED FAST
SET !EXTRACT_TEST_POPUP NO
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0
SET !LOOP
SET !DATASOURCE 01_urls.csv
FILTER TYPE=IMAGES STATUS=ON

SET Reload_DataSource_Line EVAL("var x; y='{{!LOOP}}';w='{{!COL2}}'; if(y%w ==0); x=x++;")
PROMPT {{Reload_DataSource_Line}}
SET !DATASOURCE_LINE {{Reload_DataSource_Line}}

Hum, yummy-yummy ah-ah...!, interesting Scenario...! :D

I can think of several ways to implement that, I think the "easiest" would be to specify a Start_Row and a Start_Loop within that Row (for both, Default=1), and using a mini-Temp File or the OS Clipboard, keep track of the current/next Row + Loop within that Row, to reuse in the next Loop of course... :idea:

That would allow you if for example during "handling" Row_17 (that you want to loop 222x times...!), "stg" goes wrong at Loop_101 and the Script aborts for any reason, you could re-start the Script again directly from Row_17 + Loop_101. I guess you won't want to run the first 100 Loops for that Row again, and certainly not the first 16 Rows again, I guess...!
And if/when stg goes wrong, a simple Paste (if using the Clipboard) in some Text Doc, or even in your Script from the Macro Editor would already tell you how far the Script went and where exactly it stopped... 8)

It's not very difficult, I let you (try to) implement it, or at least make a Start/Attempt, even if I guess that might be already a little bit "High Level", but hum..., I don't want to write your whole Script, that's a bit "too easy", you need to "suffer" a little bit, ah-ah...! :twisted:
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 7714
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Conditional EVAL going to certain urls

by a2515125 on Wed Oct 10, 2018 8:00 am

I cannot think of how to loop and compute !COL1 & !COL2 in this case
too many variable that I think it is totally beyond my knowledge......Orz
my brain struggling...couple days of this pb....


!COL1 & !COL2 need to be loop next........
But I dont know how to express
sorry I am stuck very deeply.........

Code: Select all

VERSION BUILD=8970419 RECORDER=FX
SET !EXTRACT_TEST_POPUP
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0
SET !DATASOURCE 01_urls.csv
SET !LOOP
FILTER TYPE=IMAGES STATUS=OFF

'---------------problem part-------------------

SET Reload_DataSource_Line EVAL("var x; w='{{!COL2}}'; y='{{!LOOP}}'; if(y%w==0){x=y/w;} else{x=1;}; x;")
SET !DATASOURCE_LINE {{!LOOP}}

SET reload EVAL("var x; y='{{!LOOP}}'; w='{{!COL2}}'; url='{{!COL1}}'; if(y%w==0){x=url;} else{x='';}; x;")
URL GOTO={{reload}}

'---------------problem part-------------------

a2515125
 
Posts: 102
Joined: Mon Dec 05, 2016 8:37 pm

Re: Conditional EVAL going to certain urls

by chivracq on Thu Oct 11, 2018 9:13 am

a2515125 wrote:I cannot think of how to loop and compute !COL1 & !COL2 in this case
too many variable that I think it is totally beyond my knowledge......Orz
my brain struggling...couple days of this pb....

!COL1 & !COL2 need to be loop next........
But I dont know how to express
sorry I am stuck very deeply.........

Code: Select all
VERSION BUILD=8970419 RECORDER=FX
SET !EXTRACT_TEST_POPUP
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0
SET !DATASOURCE 01_urls.csv
SET !LOOP
FILTER TYPE=IMAGES STATUS=OFF

'---------------problem part-------------------

SET Reload_DataSource_Line EVAL("var x; w='{{!COL2}}'; y='{{!LOOP}}'; if(y%w==0){x=y/w;} else{x=1;}; x;")
SET !DATASOURCE_LINE {{!LOOP}}

SET reload EVAL("var x; y='{{!LOOP}}'; w='{{!COL2}}'; url='{{!COL1}}'; if(y%w==0){x=url;} else{x='';}; x;")
URL GOTO={{reload}}

'---------------problem part-------------------

Hum-hum-hum, you are going to need to try "a little bit harder", your 4 Lines look a bit like a "random" Copy&Paste to me, you need to think a little bit "logically" and to (try to) understand what you are doing... :roll:

"Demystifying" those 4 Lines:
Code: Select all
SET Reload_DataSource_Line EVAL("var x; w='{{!COL2}}'; y='{{!LOOP}}'; if(y%w==0){x=y/w;} else{x=1;}; x;")
SET !DATASOURCE_LINE {{!LOOP}}

SET reload EVAL("var x; y='{{!LOOP}}'; w='{{!COL2}}'; url='{{!COL1}}'; if(y%w==0){x=url;} else{x='';}; x;")
URL GOTO={{reload}}

You cannot use '!COL2' in the 1st 'EVAL()' before even specifying the '!DATASOURCE_LINE'..., as even if it ueberhaupt "works" (meaning that iMacros will try to go and fetch some Cell in the DataSource), I don't really know what the Default Behaviour will be, I guess it will probably always fetch the Col_2 from Row_1..., or maybe, it will apply and follow '!LOOP' by Default, but that still wouldn't work for what you want from your Scenario...

And that Method worked in your previous Case/Thread because you had a fixed Nested Loop with a fixed Modulo that you can apply to the raw '!LOOP' to compute the Row_Nb, but it won't work in this current Case because your Modulo is not fixed anymore... Still following...!? :wink:

This is why I mentioned that you would need to use a 'Start_Row' and a 'Start_Loop' and then have your Script "communicate" with itself between each Loop, to know which Row + Loop_Nb within that Row it handled in the previous Loop/Run..., but your mini-Script doesn't try to handle that "Self-Communication" Mechanism, nor uses any 'Start_xxx' Vars like I suggested...

You cannot "really" compute from Scratch the Row_Nb + Inner_Loop from the raw '!LOOP'...
Well, it is possible to implement, that's actually one of the "several Solutions" I mentioned that I could think of, but hum..., I discarded it as being a little bit complex and cumbersome, even if that would be an excellent Maths Problem for 16-17 years old Kids in Secondary School as it is somewhat related to the Fibonacci Sequence, ah-ah...!, but you would need to do already a bit of "Preparation" from Excel for your '.CSV' by including your complete Col_2 in Row_1 (using 'Paste Special...' + 'Transpose') + all Temp Sums corresponding to each Cell...
=> That would give stg like:
Code: Select all
2,3,1,17,13,...
2,5,6,23,36,...

And using 'EVAL()' you would still need to identify for example that [6 < !LOOP=18 <= 23] => Need to use Row=4...!
A bit cumbersome like I said, and the Maths Functions are a bit "limited" in the 'Maths' Object in JS, you would need to resort to some Array and String Functions to "simulate" some Maths Functions... It can be done, I kind of "wrote" it my Head, but pfff..., it's a bit a weird Sequence of Workaround on Workaround...! Now I nearly hope you got lost...!?, good...! Cumbersome I said...! :shock:

And that's why I came up with the Solution I mentioned would be easier/the easiest...!! :idea:
=> Follow my "Advice" and try to implement that Solution... :idea:
And trust me, I'm usually good at finding/identifying when I call stg the "easiest" Solution, ah-ah...! :twisted:
=> You don't even need any cumbersome 'Modulo' whatever, just a simple 'IF(a<=b) ELSE' Statement... 8)

Nou..., good luck then...! :wink:
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 7714
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Conditional EVAL going to certain urls

by a2515125 on Thu Oct 11, 2018 7:16 pm

thanks to reply me so fast......

yes I am stuck by not knowing how to let my script jumping into ROW_2..ROW_3...in Both COL_1 and COL_2

I dont use 'Start_Row' and a 'Start_Loop' because I do not know how to start do it.......after reading your suggestion

here is what I figure out a bit......

not sure if i am on the right way...... :idea:


------------code-----------

SET start_loop Eval(" extract number from !COL2 in csv file : 5/3/1/17/13.... ").....

SET start_row Eval(" whenever var x = {{start_loop}}, y will move to next row; y = y++ ").....


SET !DATASOURCE_LINE {{start_row}}

SET reload EVAL("var x; y='{{start_loop}}'; w='{{!COL2}}'; url='{{!COL1}}'; if(y==w){x=url;} else{x='';}; x;")
URL GOTO={{reload}}

------------code-----------
a2515125
 
Posts: 102
Joined: Mon Dec 05, 2016 8:37 pm

Re: Conditional EVAL going to certain urls

by chivracq on Fri Oct 12, 2018 10:48 am

a2515125 wrote:thanks to reply me so fast......

yes I am stuck by not knowing how to let me script jumping into ROW_2..ROW_3...in Both COL_1 and COL_2

I dont use 'Start_Row' and a 'Start_Loop' because I do not know how to start do it.......after reading your suggestion

here is what I figure out a bit......

not sure if it is on the right way...... :idea:

Code: Select all
SET start_row Eval(" ? ").....
SET start_loop Eval(" ? ").....

SET !DATASOURCE_LINE {{start_row}}

SET reload EVAL("var x; y='{{start_loop}}'; w='{{!COL2}}'; url='{{!COL1}}'; if(y==w){x=url;} else{x='';}; x;")
URL GOTO={{reload}}

NOTE:
This is still in early 'DRAFT' Mode, but I'm posting it already as I see you checking the Forum regularly, I guess I got a bit "bored" last night :oops: and started to write a POC, not finished, not tested, still buggy, but it's already WE and I'm always a bit "busy" during WE's, (I'm a DJ and I have a Social Life...), so I'm not sure when I'll be able to continue that Script, but that should already give you an "Idea"... 8)

Already have a look and try to understand what I am "doing", the Syntax I use for example in my 'EVAL()' Statements is much easier to follow and to reuse than the one in your "own" 'EVAL()' Statements which is pretty "messy" and not consistent...

The main "Difficulty" in the Script resides in the correct Order for all 'EVAL()' Statements... :idea:

>>>

For both 'Start_xxx' Vars, I had already mentioned in my first Reply that they should be =1 by Default... The very first time you will start looping your Script, you want to start from the very first Row (=Row_1) and from the first Loop within that Row.
And when you (re)-run your Script, the Clipboard doesn't contain any Info about some previous Run at the first Loop, so it wouldn't know where to start...
And you will manually edit those 2 Values if your Script aborted, say in the middle of your Row_17 that you want to loop 222x times... (But I already explained that Mechanism in my first Reply...)

And that would give stg like...:
Code: Select all
SET Start_Row 1
SET Start_Loop 1

'Expected Format in Clipboard: "Previous_Row#Previous_Loop" Ex: "1#1" or "1#2" or "4#10" etc...
SET Prev_Row EVAL("var sr='{{Start_Row}}', cb='{{!CLIPBOARD}}', n='{{!LOOP}}'; var x,y,z; x=cb.split('#'); if(n==1){z=sr;} else{z=x[0];}; z;")
SET !DATASOURCE_LINE {{Prev_Row}}
SET Use_Loop EVAL("var sl='{{Start_Loop}}', c2='{{!COL2}}', cb='{{!CLIPBOARD}}', n='{{!LOOP}}'; var x,y,z; x=cb.split('#'); if(n==1){z=sl;} else{z=x[1];}; z;")
SET !LOOP {{Use_Loop}}

'SET Use_Row EVAL("var pr='{{Prev_Row}}', n='{{!LOOP}}'; var x,y,z; x=cb.split('#'); if(n==1){z=sr;} else{z=x[0];}; z;")

'SET reload EVAL("var x; y='{{start_loop}}'; w='{{!COL2}}'; url='{{!COL1}}'; if(y==w){x=url;} else{x='';}; x;")
'URL GOTO={{reload}}

(DRAFT Mode: Not finished, not tested, still buggy...)
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 7714
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Conditional EVAL going to certain urls

by a2515125 on Mon Oct 15, 2018 3:58 am

thanks.....yes I know you are busy on we....it is ok :wink:
and very appreciate for your big help for 2yrs :P
You know I am willing to pay for your help :) :idea:
iMacros is my first coding experience and I love it so much thanks to you !



Code: Select all
SET !DATASOURCE 01_urls.csv
SET !ERRORIGNORE YES
SET Start_Row 1
SET Start_Loop 1

'Expected Format in Clipboard: "Previous_Row#Previous_Loop" Ex: "1#1" or "1#2" or "4#10" etc...

SET Prev_Row EVAL("var sr='{{Start_Row}}', cb='{{!CLIPBOARD}}', n='{{!LOOP}}'; var x,y,z; x=cb.split('#'); if(n==1){z=sr;} else{z=x[0];}; z;")
PROMPT {{Prev_Row}}
SET !DATASOURCE_LINE {{Prev_Row}}
SET Use_Loop EVAL("var sl='{{Start_Loop}}', c2='{{!COL2}}', cb='{{!CLIPBOARD}}', n='{{!LOOP}}'; var x,y,z; x=cb.split('#'); if(n==1){z=sl;} else{z=x[1];}; z;")
PROMPT {{Use_Loop}}
a2515125
 
Posts: 102
Joined: Mon Dec 05, 2016 8:37 pm

Re: Conditional EVAL going to certain urls

by a2515125 on Thu Oct 18, 2018 8:14 pm

Image
----here is my trying on your code----

Expected Format in Clipboard:2#3 (which is row2 from csv)

at the first run:
PROMPT {{Prev_Row}} & PROMPT {{Use_Loop}} debug shows: 1/1

after the first run....N times running(loop mode)
PROMPT {{Prev_Row}} & PROMPT {{Use_Loop}} debug keep showing: 2/3
PROMPT {{Prev_Row}} & PROMPT {{Use_Loop}} debug keep showing: 2/3
PROMPT {{Prev_Row}} & PROMPT {{Use_Loop}} debug keep showing: 2/3



Therefore, my question is how to put the "row 3" from csv file which is "3#1" on my clipboard after running the "row 2" "2#3"    :idea:
my clipboard should be changeable after looping right? so that is my problem for now
a2515125
 
Posts: 102
Joined: Mon Dec 05, 2016 8:37 pm


Return to General Support & Discussions

Who is online

Users browsing this forum: No registered users and 8 guests

-->