Need a way to compare multiple extract values

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.

Moderators: Community Moderators, iMacros Moderators

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.

Need a way to compare multiple extract values

by fadetoblack on Tue Jan 31, 2017 8:46 am

FF47 imacros 8.9.7 Windows 7

Chivraq dazzle me with your wonderful workaround magic please :D I am working on something new and cant get my head around how to do it . Basically I need to check 5 positions on the page every minute to see if the text/username exists,and if not then to run 1 macro that will always be the same master macro. I know how to do everything else like if found then url goto another macro, I just cant get my head around dealing with the multiple extractions from 5 different positions on the page . The code so far is below

Code: Select all
TAG POS=1 TYPE=A ATTR=ID:username_copy EXTRACT=TXT
SET !VAR2 EVAL("var s=\"{{!EXTRACT}}\"; if(s.match(\"example\")){url=\"imacros://run/?m=#1.iim\";} else url=\"imacros://run/?m=#2.iim\"; url;")
URL GOTO={{!VAR2}}
TAG POS=2 TYPE=A ATTR=ID:username_copy EXTRACT=TXT
SET !VAR2 EVAL("var s=\"{{!EXTRACT}}\"; if(s.match(\"example\")){url=\"imacros://run/?m=#1.iim\";} else url=\"imacros://run/?m=#2.iim\"; url;")
URL GOTO={{!VAR2}}
TAG POS=3 TYPE=A ATTR=ID:username_copy EXTRACT=TXT
SET !VAR2 EVAL("var s=\"{{!EXTRACT}}\"; if(s.match(\"example\")){url=\"imacros://run/?m=#1.iim\";} else url=\"imacros://run/?m=#2.iim\"; url;")
URL GOTO={{!VAR2}}
TAG POS=4 TYPE=A ATTR=ID:username_copy EXTRACT=TXT
SET !VAR2 EVAL("var s=\"{{!EXTRACT}}\"; if(s.match(\"example\")){url=\"imacros://run/?m=#1.iim\";} else url=\"imacros://run/?m=#2.iim\"; url;")
URL GOTO={{!VAR2}}
TAG POS=5 TYPE=A ATTR=ID:username_copy EXTRACT=TXT
SET !VAR2 EVAL("var s=\"{{!EXTRACT}}\"; if(s.match(\"example\")){url=\"imacros://run/?m=#1.iim\";} else url=\"imacros://run/?m=#2.iim\"; url;")
URL GOTO={{!VAR2}}




This code is correct in principle but isnt efficient, I want to check all 5 positions at once, once a minute , if text found then all good and return to sleep for 60 secs. If not found then launch the master macro ..... Am i making sense ? :)
fadetoblack
 
Posts: 24
Joined: Sat Oct 30, 2010 5:50 am

Re: Need a way to compare multiple extract values

by chivracq on Tue Jan 31, 2017 12:12 pm

fadetoblack wrote:
Code: Select all
FF47 imacros 8.9.7  Windows 7


Chivraq dazzle me with your wonderful workaround magic please :D I am working on something new and cant get my head around how to do it . Basically I need to check 5 positions on the page every minute to see if the text/username exists,and if not then to run 1 macro that will always be the same master macro. I know how to do everything else like if found then url goto another macro, I just cant get my head around dealing with the multiple extractions from 5 different positions on the page . The code so far is below
Code: Select all
TAG POS=1 TYPE=A ATTR=ID:username_copy EXTRACT=TXT
SET !VAR2 EVAL("var s=\"{{!EXTRACT}}\"; if(s.match(\"example\")){url=\"imacros://run/?m=#1.iim\";} else url=\"imacros://run/?m=#2.iim\"; url;")
URL GOTO={{!VAR2}}
TAG POS=2 TYPE=A ATTR=ID:username_copy EXTRACT=TXT
SET !VAR2 EVAL("var s=\"{{!EXTRACT}}\"; if(s.match(\"example\")){url=\"imacros://run/?m=#1.iim\";} else url=\"imacros://run/?m=#2.iim\"; url;")
URL GOTO={{!VAR2}}
TAG POS=3 TYPE=A ATTR=ID:username_copy EXTRACT=TXT
SET !VAR2 EVAL("var s=\"{{!EXTRACT}}\"; if(s.match(\"example\")){url=\"imacros://run/?m=#1.iim\";} else url=\"imacros://run/?m=#2.iim\"; url;")
URL GOTO={{!VAR2}}
TAG POS=4 TYPE=A ATTR=ID:username_copy EXTRACT=TXT
SET !VAR2 EVAL("var s=\"{{!EXTRACT}}\"; if(s.match(\"example\")){url=\"imacros://run/?m=#1.iim\";} else url=\"imacros://run/?m=#2.iim\"; url;")
URL GOTO={{!VAR2}}
TAG POS=5 TYPE=A ATTR=ID:username_copy EXTRACT=TXT
SET !VAR2 EVAL("var s=\"{{!EXTRACT}}\"; if(s.match(\"example\")){url=\"imacros://run/?m=#1.iim\";} else url=\"imacros://run/?m=#2.iim\"; url;")
URL GOTO={{!VAR2}}

This code is correct in principle but isnt efficient, I want to check all 5 positions at once, once a minute , if text found then all good and return to sleep for 60 secs. If not found then launch the master macro ..... Am i making sense ? :)

Yeah, but hum..., checking a bit your (8) previous Threads, and big-hum...!, except from your very 1st Thread that I kind of forced you a bit to finish "neatly" with some Thanks for Tom from TechSupport, 4 years later, grrr...!, I notice from a quick Check that all your 7 later Threads are all waiting for a Follow-up or a "neat Finish" (= sharing your Solution eventually) from your Side, grrr...!:
Thread_2 // Thread_3 // Thread_4 // Thread_5 // Thread_6 // Thread_7 // Thread_8
Even for Thread_7 where nobody replied (I am no JavaScript Guru myself and I guess I expected sbd else to answer it, or I was a bit busy at that time that I didn't react), you are expected after a few days to bump your Thread if you are still looking for a Solution, or to share your Solution if you managed to solve it by yourself (or from some other Forum maybe), to make the Thread useful for other Users as well, and this applies to all Threads on the Forum actually...

=> So..., could you first finish all those 7 previous Threads "a bit neatly" before I'll be willing to go "magically creative" to do some Digging in this current one...? :idea:
At least you got the "CIM"/"FCIM"/"FCI" part correct now when you open a Thread, ah-ah...! Good...! :D

>>>

(And this current Thread doesn't sound very complicated, you should be able to find one Solution by yourself (and there are several, even if I have the Feeling you are "aiming" at a pretty cumbersome one, ah-ah...!) , from seeing what you were "doing" in all your previous Threads, and especially after using iMacros since at least 2010, ugh...! But don't worry, I'll help you further after you've finished your other Threads a bit correctly...)
- (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: 6477
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Need a way to compare multiple extract values

by fadetoblack on Tue Jan 31, 2017 1:22 pm

Understood , I will get that done .
fadetoblack
 
Posts: 24
Joined: Sat Oct 30, 2010 5:50 am

Re: Need a way to compare multiple extract values

by chivracq on Thu Feb 02, 2017 6:32 pm

fadetoblack wrote:Understood , I will get that done .

Oh yeah, sorry, I had noticed indeed that you had updated all your previous Threads after my last Post, nearly IRT ah-ah, I'll respond/follow up where "necessary", there was one "Solution" that I didn't understand, but I would need for each to go "digging" again into the Thread, which takes some time, and new Threads keep coming in, so I didn't find the Time yet, but I guess you would like some Feedback/Answer about this current Thread which must have your "Focus" at this moment I reckon...

Well, I said that it was not very complicated but that you had chosen a "cumbersome" Path, ah-ah...!

Well, one thing you have to realize, is that the "URL GOTO=imacros://run/?m=#1.iim" Syntax you are using is Officially not supported by iMacros TechSupport and meant more like a Workaround to '.iim' Scripts like 'iimPlay()' in '.js' Scripts.

And there is a BIG Difference between both Syntaxes, when some '.js' Script is launching an '.iim' Macro (created on the fly in the '.js' Script or as an '.iim' File), the '.js' Script will wait for the '.iim' Macro to finish, to retrieve some Return Code and the Content of '!EXTRACT' eventually before processing any further Commands while when a Macro is launched from the 'URL GOTO=imacros://run/?m=' Syntax, it doesn't know anything from what happened before, all (Built-in) Vars get reset and once finished, it will never return to the Macro that launched it...

Which means that your whole Script is actually only 1 Block of Code:
Code: Select all
SET !VAR2 EVAL("var s=\"{{!EXTRACT}}\"; if(s.match(\"example\")){url=\"imacros://run/?m=#1.iim\";} else url=\"imacros://run/?m=#2.iim\"; url;")
URL GOTO={{!VAR2}}
TAG POS=2 TYPE=A ATTR=ID:username_copy EXTRACT=TXT
SET !VAR2 EVAL("var s=\"{{!EXTRACT}}\"; if(s.match(\"example\")){url=\"imacros://run/?m=#1.iim\";} else url=\"imacros://run/?m=#2.iim\"; url;")
URL GOTO={{!VAR2}}

Everything after the first 'URL GOTO' will never be executed...!
So I don't know where you got your "This code is correct in principle..." from, but that cannot be true, ah-ah...!

The 'run/?m=' Syntax is OK for 2 or 3 "Jumps" but I find it very cumbersome in your Case, with 5 Jumps apparently which become 10 Jumps as you each time need to split your Logic into 2 Macros, and even if you think you are calling 5 times '#1.iim', you still need 5 Copies of the same Macro with each time a different Name as it will then each time have to call another Macro for the complete Workflow that your Scenario implies. And same thing with '#2.iim', ah-ah...! Very cumbersome, I told you...
And if anything "happens" in one of the 15 Macros involved in total (ah-ah...!), it will be a complete hassle to debug and once you modify stg in one Macro, you probably need to replicate that Change in the 4 similar Macros, pffff..., Maintenance Headache...!

The logical way in your Case would be to have a Main '.js' Script that will handle all the Conditional Workflow, with one first '.iim' Macro first doing the 5 Extracts and returning the Content to the '.js' Script that will then launch the 5x '#1.iim' or '#2.iim' Macros depending on each Extract.

And depending on what you do in those 2 '#1.iim'/'#2.iim' Macros, and especially how similar/different they are from each other, it might be possible to embed them directly into one Main '.iim' Macro and to activate/deactivate them alternately using 'EVAL()', hum, could be a Solution, but I don't have "the complete picture" of what you are doing or want to do...

I have developed "Techniques" to avoid '.js' Scripts, which implies cumbersome Solutions sometimes but from what I saw from your previous Threads, you've already used '.js' Scripts, so there is no need for you to follow the same path, especially if I find your path cumbersome, I'm normally the last Person to have such an Opinion", ah-ah...! Pure '.iim' fits my Needs but I would think you can better embrace a '.js' Script from the Info I've got that you've provided...

>>>

Hum, and concerning your '15 Macros' cumbersome Scenario, I would already have a "Solution" to lower that Number to 2 or 3 Macros, but pfff..., it's actually applying Workaround on Workaround, and you would need to find them by yourself, plus in this Case, adding some heavy Logging + Level of Checks to ensure Reliability and Debugging in case of Pb of the whole Implementation... (But again, it is very cumbersome, more or less recreating Functionality that exists Standard in iMacros with '.js' Scripts...)
Well, you can always have a look at the following Thread where I explained a bit what I have in mind... (Option Nb_4.)
- (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: 6477
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Need a way to compare multiple extract values

by fadetoblack on Mon Feb 06, 2017 6:24 pm

Thanks for the detailed response :) In the end I thought I would just go for it with the chained macros x5 , so basically macro 1 checks position one, then if not found onto macro 2 which checks pos 2, then if not found onto macro 3 etc. I made a master "wait" macro to revert to if any macro finds the text on any position (1-5). The main macro waits for 2 minutes and then goes to macro 1 (via url goto at the end of the macro). Obviously, if macro 5 still does not find the text then the main posting macro is triggered , which obv posts and then forwards to macro 1 to resume the cycle (via url goto again of course) . It's actually working flawlessly and way better than I thought it would so I am pretty happy :)
fadetoblack
 
Posts: 24
Joined: Sat Oct 30, 2010 5:50 am

Re: Need a way to compare multiple extract values

by chivracq on Mon Feb 06, 2017 7:13 pm

fadetoblack wrote:Thanks for the detailed response :) In the end I thought I would just go for it with the chained macros x5 , so basically macro 1 checks position one, then if not found onto macro 2 which checks pos 2, then if not found onto macro 3 etc. I made a master "wait" macro to revert to if any macro finds the text on any position (1-5). The main macro waits for 2 minutes and then goes to macro 1 (via url goto at the end of the macro). Obviously, if macro 5 still does not find the text then the main posting macro is triggered , which obv posts and then forwards to macro 1 to resume the cycle (via url goto again of course) . It's actually working flawlessly and way better than I thought it would so I am pretty happy :)

OK-OK then, I think I would probably come up with a different "Workflow Strategy" for myself if I had all Info about your Scenario but if it works for you and you are happy, then, well..., I'm happy too I guess, ah-ah...! :D

I didn't go digging back in your previous Threads as I need for each to dig completely into it again which is always a bit of a hassle 1 or 2 years later, and the Forum is a bit busy at the moment, I will check them when I have the time or if I "encounter" them again, related to other Threads...
I guess/hope you selected to receive Notifications if sbd replies to any of your Threads, I know there was one I had not really understood your final Post/Solution and another one about the 'Jobbit' or stg like that, some other Macro Language at the OS-API Level, I was interested in...
- (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: 6477
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)


Return to General Support & Discussions

Who is online

Users browsing this forum: No registered users and 13 guests

-->