Execute if above 70%

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.

Execute if above 70%

by Capyn on Fri Jul 07, 2017 5:50 am

(F)CIM = FF 8.9.7, FF54, MacOS X_10_10.1

Hi there,

I'm trying to get iMacro to execute a command if x is 70% or higher: TAG POS=2 TYPE=DIV ATTR=TXT:70%

If iMacro can see that x is higher than 70% I can then formulate an execution command that follows after, else wait 90 seconds before refreshing the page.

I'm not too familiar with EVAL, but I'd imagine it would involve this?
Capyn
 
Posts: 22
Joined: Sun May 14, 2017 4:47 pm

Re: Execute if above 70%

by chivracq on Fri Jul 07, 2017 6:53 am

Capyn wrote:(F)CIM =
Code: Select all
FF 8.9.7, FF54, MacOS X_10_10.1


Hi there,

I'm trying to get iMacro to execute a command if x is 70% or higher:
Code: Select all
TAG POS=2 TYPE=DIV ATTR=TXT:70%


If iMacro can see that x is higher than 70% I can then formulate an execution command that follows after, else wait 90 seconds before refreshing the page.

I'm not too familiar with EVAL, but I'd imagine it would involve this?

The "M" in "(F)CIM" stands for "Missing" btw...

But yep, using 'EVAL()' in pure '.iim' is the way, here is some recent very similar Thread as an Example to explain the Principle (and to avoid one "Difficulty")...:
- Greater Than problem in Eval
- (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: 6473
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Execute if above 70%

by Capyn on Tue Jul 11, 2017 3:23 am

Great thank you!

I have had a look at the other thread,

Does this look correct?

Code: Select all
TAG POS=4 TYPE=DIV ATTR=TXT:*&&TXT: EXTRACT=TXT 

SET !EXTRACT_TEST_POPUP NO
SET !VAR1 70
SET !VAR2 EVAL (""var c='{{!EXTRACT}}’; var t = '{{!VAR1}}'; if ((c*1)>(t*1)) 'YES'; else 'NO';”)




Thank you!
Capyn
 
Posts: 22
Joined: Sun May 14, 2017 4:47 pm

Re: Execute if above 70%

by chivracq on Tue Jul 11, 2017 10:08 am

Capyn wrote:Great thank you!

I have had a look at the other thread,

Does this look correct?

Code: Select all
TAG POS=4 TYPE=DIV ATTR=TXT:*&&TXT: EXTRACT=TXT 

SET !EXTRACT_TEST_POPUP NO
SET !VAR1 70
SET !VAR2 EVAL (""var c='{{!EXTRACT}}’; var t = '{{!VAR1}}'; if ((c*1)>(t*1)) 'YES'; else 'NO';”)


Thank you!

Well, not quite...:
- If you get "70%" from the Extract, you need to remove the '%' from that String if you want to be able to do some Arithmetic Comparison...
- You have an extra Double Quote at the beginning of the 'EVAL()'...
- You have an extra Space after the "EVAL" Keyword, it doesn't really play a role for v8.9.7 for FF, but there is one Browser and some specific Version of iMacros (I don't remember which one) that doesn't accept that extra Space...
- Instead of "spitting out" a 'YES'/'NO' that you probably cannot reuse directly unless you want to toggle some 'YES/NO' Command like for example:
Code: Select all
SET !ERRORIGNORE {{!VAR2}}
... => You can better spit out some '1'/'0' for example that you can reuse on your "Conditional" next 'TAG' Statement with
Code: Select all
SET !ERRORIGNORE YES
TAG POS={{!VAR2}} TYPE=...
'TAG POS=0' won't do anything, ah-ah...! But you need '!ERRORIGNORE' as iMacros doesn't like it, ah-ah...!
- And hum, I'm not familiar with this 'if/else' Syntax this other User was using, even if it seems to work, here is the Syntax I use myself...:
Code: Select all
VERSION BUILD=8820413 RECORDER=FX
SET !EXTRACT_TEST_POPUP NO
SET !ERRORIGNORE YES
TAB T=1

'SET !EXTRACT "70.000001%"
TAG POS=4 TYPE=DIV ATTR=TXT:*&&TXT: EXTRACT=TXT

SET !VAR1 70
SET !VAR2 EVAL("var s='{{!EXTRACT}}'; var v1='{{!VAR1}}'; var d,z; d=s.replace('%',''); if((d*1)>(v1*1)){z=1;} else{z=0;}; z;")

PROMPT EXTRACT:<SP>_{{!EXTRACT}}_<BR>VAR1:<SP>_{{!VAR1}}_<BR><BR>VAR2:<SP>_{{!VAR2}}_
(Tested on iMacros v8.8.2, PM v26.3.3 (=FF47), Win10-x64.)

OK, this one should work... I don't really know why, but I had to retype the complete 'EVAL()' Statement myself after I had tried to reuse part of yours from a Copy&Paste and to edit it to its final form..., I kept getting some RuntimeError about a missing ';' otherwise, while it looked OK to me, maybe coming from some "strange" Character coming from some "exotic" Editor with some different Character Set that my Browser and its JS Compile Engine would not accept... Dunno... But I tried on iMacros for FF v8.9.7 + FF54 as well and I would get the same RuntimeError...
- (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: 6473
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Execute if above 70%

by Capyn on Mon Jul 24, 2017 4:22 am

Awesome chivracq thanks so much!!!
That looks great, I appreciate your time!! :)

I now need to find out how to do my SET command once the conditions are met. I have an idea what I want for my actions, for example, if it is above 70% is met then commence actions, otherwise if not then REFRESH every 3minutes. How would this look in code?


For example if condition is above 70% commence the following action:


Code: Select all
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT=test2
TAG POS=1 TYPE=BUTTON FORM=ID:tsf ATTR=ID:_fZl

TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT=test3
TAG POS=1 TYPE=BUTTON FORM=ID:tsf ATTR=ID:_fZl

TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT=test4
TAG POS=1 TYPE=BUTTON FORM=ID:tsf ATTR=ID:_fZl

TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT=test5
TAG POS=1 TYPE=BUTTON FORM=ID:tsf ATTR=ID:_fZl

TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT=test6
TAG POS=1 TYPE=BUTTON FORM=ID:tsf ATTR=ID:_fZl

TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT=test7
TAG POS=1 TYPE=BUTTON FORM=ID:tsf ATTR=ID:_fZl

TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT=test8
TAG POS=1 TYPE=BUTTON FORM=ID:tsf ATTR=ID:_fZl

TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT=test9
TAG POS=1 TYPE=BUTTON FORM=ID:tsf ATTR=ID:_fZl

!LOOP


So long as 70% is met, it will keep looping the above actions. Eventually the condition will drop below 70% thus making the IF statement REFRESH page until condition is back equaling 70% and or above.
Capyn
 
Posts: 22
Joined: Sun May 14, 2017 4:47 pm

Re: Execute if above 70%

by chivracq on Mon Jul 24, 2017 6:10 am

Capyn wrote:Awesome chivracq thanks so much!!!
That looks great, I appreciate your time!! :)

I now need to find out how to do my SET command once the conditions are met. I have an idea what I want for my actions, for example, if it is above 70% is met then commence actions, otherwise if not then REFRESH every 3minutes. How would this look in code?


For example if condition is above 70% commence the following action:


Code: Select all
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT=test2
TAG POS=1 TYPE=BUTTON FORM=ID:tsf ATTR=ID:_fZl

TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT=test3
TAG POS=1 TYPE=BUTTON FORM=ID:tsf ATTR=ID:_fZl

TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT=test4
TAG POS=1 TYPE=BUTTON FORM=ID:tsf ATTR=ID:_fZl

TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT=test5
TAG POS=1 TYPE=BUTTON FORM=ID:tsf ATTR=ID:_fZl

TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT=test6
TAG POS=1 TYPE=BUTTON FORM=ID:tsf ATTR=ID:_fZl

TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT=test7
TAG POS=1 TYPE=BUTTON FORM=ID:tsf ATTR=ID:_fZl

TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT=test8
TAG POS=1 TYPE=BUTTON FORM=ID:tsf ATTR=ID:_fZl

TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT=test9
TAG POS=1 TYPE=BUTTON FORM=ID:tsf ATTR=ID:_fZl

!LOOP


So long as 70% is met, it will keep looping the above actions. Eventually the condition will drop below 70% thus making the IF statement REFRESH page until condition is back equaling 70% and or above.

Hum, you keep using the Term "SET Command" but that's a bit vague because 'SET' is used for all kinds of Variables used in iMacros, User Defined Vars and all Built-in Vars like '!DATASOURCE' / '!TIMEOUT_PAGE' / '!ERRORIGNORE' / 'EXTRACT' / etc..., so "SET Command" doesn't mean much, it's the Var after the 'SET' Command which is important...

But yep, a Technique I use indeed in my own Macros to conditionally execute or skip complete Sections of a Macro is to conditionally switch to a "fake" TAB_2 with a "fake" URL where that Section of Code won't do anything..., and then to come back to TAB_1 at the end of the optional Section which can be the end of the Macro if you loop it and the start of the next Loop will take care of the Refresh.
- (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: 6473
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Execute if above 70%

by Capyn on Mon Jul 24, 2017 6:23 am

Oh of course, Sorry I was meaning "SET", thanks for pointing out! :)

I see what you mean, I think, so an example would be;

Code: Select all
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0

SET !EXTRACT_TEST_POPUP NO
SET !EXTRACT NULL
TAG POS=4 TYPE=DIV ATTR=TXT:*&&TXT: EXTRACT=TXT

SET !VAR1 70
SET !VAR2 EVAL("var s='{{!EXTRACT}}'; var v1='{{!VAR1}}'; var d,z; d=s.replace('%',''); if((d*1)>(v1*1)){z=1;} else{z=0;}; z;")

SET Change_TAB EVAL("var s='{{!EXTRACT}}'; var z; if(s=='YES'){z=2;} else{z=1;}; z;")
TAB T={{Change_TAB}}

TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT=test2
TAG POS=1 TYPE=BUTTON FORM=ID:tsf ATTR=ID:_fZl

TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT=test3
TAG POS=1 TYPE=BUTTON FORM=ID:tsf ATTR=ID:_fZl

TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT=test4
TAG POS=1 TYPE=BUTTON FORM=ID:tsf ATTR=ID:_fZl

TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT=test5
TAG POS=1 TYPE=BUTTON FORM=ID:tsf ATTR=ID:_fZl

TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT=test6
TAG POS=1 TYPE=BUTTON FORM=ID:tsf ATTR=ID:_fZl

TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT=test7
TAG POS=1 TYPE=BUTTON FORM=ID:tsf ATTR=ID:_fZl

TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT=test8
TAG POS=1 TYPE=BUTTON FORM=ID:tsf ATTR=ID:_fZl

TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT=test9
TAG POS=1 TYPE=BUTTON FORM=ID:tsf ATTR=ID:_fZl


SET URL_TAB2 EVAL("var t='{{Change_TAB}}', u='{{URL_Webmail}}'; var z; if(t==2){z=u;} else{z='';}; z;")
URL GOTO={{URL_TAB2}}


Does that look correct?

Cheers!
Capyn
 
Posts: 22
Joined: Sun May 14, 2017 4:47 pm


Return to General Support & Discussions

Who is online

Users browsing this forum: No registered users and 7 guests

-->