Nested if-else within EVAL()

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.

Nested if-else within EVAL()

by Aditya93 on Sat Jan 06, 2018 9:22 am

hi

i wanted to know how i can wrtie this statement

Code: Select all
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix1<ix2){x1 = 119;}; if(ix1>ix2}{x1 = 125;}; else{x1 = ix10;}; x1;")


only the first if is read after that it goes to straight else

Code: Select all
VERSION BUILD=10022823
Windows 7 x64 (English)
Imacro Browser V10.0.2.2823
Included Demo macro works
Aditya93
 
Posts: 39
Joined: Fri Nov 24, 2017 10:34 pm

Re: Nested if-else within EVAL()

by chivracq on Sun Jan 07, 2018 7:25 pm

Aditya93 wrote:hi

i wanted to know how i can wrtie this statement

Code: Select all
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix1<ix2){x1 = 119;}; if(ix1>ix2}{x1 = 125;}; else{x1 = ix10;}; x1;")


only the first if is read after that it goes to straight else

Code: Select all
VERSION BUILD=10022823
Windows 7 x64 (English)
Imacro Browser V10.0.2.2823
Included Demo macro works

Try this one...:
Code: Select all
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix1<ix2){x1 = 119;} else if(ix1>ix2){x1 = 125;} else{x1 = ix10;}; x1;")

And I find the following Syntax easier to follow..., and it is a bit more compact...:
Code: Select all
SET !VAR4 EVAL("var ix1='{{!VAR1}}', ix2='{{!VAR2}}', ix3='{{!VAR3}}', ix10='{{!VAR4}}'; var z; if(ix1<ix2){z=119;} else if(ix1>ix2){z=25;} else{z=ix10;}; z;")
- (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: 6872
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Nested if-else within EVAL()

by Aditya93 on Tue Jan 09, 2018 10:30 pm

Code: Select all
WAIT SECONDS=1
DS CMD=CLICK X=283 Y=285 CONTENT=
WAIT SECONDS=0.3
IMAGESEARCH POS=1 IMAGE=sam_RD_119.png CONFIDENCE=93
SET !VAR1 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR1}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 119;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_125.png CONFIDENCE=93
SET !VAR1 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR1}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 125;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_169.png CONFIDENCE=93
SET !VAR1 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR1}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 169;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_175.png CONFIDENCE=93
SET !VAR1 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR1}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 175;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_219.png CONFIDENCE=93
SET !VAR1 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR1}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 219;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_269.png CONFIDENCE=93
SET !VAR1 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR1}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 269;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_275.png CONFIDENCE=93
SET !VAR1 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR1}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 275;}else{x1 = ix10;}; x1;")

WAIT SECONDS=1
DS CMD=CLICK X=457 Y=366 CONTENT=
WAIT SECONDS=0.3
IMAGESEARCH POS=1 IMAGE=sam_RD_119.png CONFIDENCE=93
SET !VAR2 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR2}}'; var x1; if(ix=='350' || ix=='351' || ix=='352'){x1 = 119;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_125.png CONFIDENCE=93
SET !VAR2 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR2}}'; var x1; if(ix=='350' || ix=='351' || ix=='352'){x1 = 125;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_169.png CONFIDENCE=93
SET !VAR2 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR2}}'; var x1; if(ix=='350' || ix=='351' || ix=='352'){x1 = 169;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_175.png CONFIDENCE=93
SET !VAR2 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR2}}'; var x1; if(ix=='350' || ix=='351' || ix=='352'){x1 = 175;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_219.png CONFIDENCE=93
SET !VAR2 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR2}}'; var x1; if(ix=='350' || ix=='351' || ix=='352'){x1 = 219;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_269.png CONFIDENCE=93
SET !VAR2 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR2}}'; var x1; if(ix=='350' || ix=='351' || ix=='352'){x1 = 269;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_275.png CONFIDENCE=93
SET !VAR2 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR2}}'; var x1; if(ix=='350' || ix=='351' || ix=='352'){x1 = 275;}else{x1 = ix10;}; x1;")


WAIT SECONDS=1
DS CMD=CLICK X=565 Y=296 CONTENT=
WAIT SECONDS=0.3
IMAGESEARCH POS=1 IMAGE=sam_RD_119.png CONFIDENCE=93
SET !VAR3 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR3}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 119;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_125.png CONFIDENCE=93
SET !VAR3 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR3}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 125;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_169.png CONFIDENCE=93
SET !VAR3 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR3}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 169;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_175.png CONFIDENCE=93
SET !VAR1 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR3}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 175;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_219.png CONFIDENCE=93
SET !VAR3 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR3}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 219;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_269.png CONFIDENCE=93
SET !VAR3 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR3}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 269;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_275.png CONFIDENCE=93
SET !VAR3 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR3}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 275;}else{x1 = ix10;}; x1;")

SET !VAR4 0


'AB
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix1==ix2 && ix2==ix3 && ix1!=' ' && ix2!=' ' && ix3!=' '){x1 = 1;} else{x1 = ix10;}; x1;")
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix3>=ix1 && ix1>ix2){x1 = 1;} else{x1 = ix10;}; x1;")
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix3>ix1 && ix1>=ix2){x1 = 1;} else{x1 = ix10;}; x1;")
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix3>ix2 && ix2>=ix1){x1 = 1;} else{x1 = ix10;}; x1;")
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix3>=ix2 && ix2>ix1){x1 = 1;} else{x1 = ix10;}; x1;")
'PROMPT {{!VAR4}}

'BC
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix1>ix2 && ix2>=ix3){x1 = 2;} else{x1 = ix10;}; x1;")
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix1>=ix2 && ix2>ix3){x1 = 2;} else{x1 = ix10;}; x1;")
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix1>=ix3 && ix3>ix2){x1 = 2;} else{x1 = ix10;}; x1;")
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix1>ix3 && ix3>=ix2){x1 = 2;} else{x1 = ix10;}; x1;")
'PROMPT {{!VAR4}}

'AC
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix2>ix1 && ix1>=ix3){x1 = 3;} else{x1 = ix10;}; x1;")
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix2>=ix1 && ix1>ix3){x1 = 3;} else{x1 = ix10;}; x1;")
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix2>=ix3 && ix3>ix1){x1 = 3;} else{x1 = ix10;}; x1;")
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix2>ix3 && ix3>=ix1){x1 = 3;} else{x1 = ix10;}; x1;")
'PROMPT {{!VAR4}}


I tried this
but sometimes the condition it selects is incorrect
like for VAR1 = 219, VAR2 = 169, VAR3 = 169
it gives out VAR4 = 1
instead of 2

mostly i noticed that it gives out wrong output in case two values are same
Aditya93
 
Posts: 39
Joined: Fri Nov 24, 2017 10:34 pm

Re: Nested if-else within EVAL()

by chivracq on Wed Jan 10, 2018 4:17 am

Aditya93 wrote:
Code: Select all
WAIT SECONDS=1
DS CMD=CLICK X=283 Y=285 CONTENT=
WAIT SECONDS=0.3
IMAGESEARCH POS=1 IMAGE=sam_RD_119.png CONFIDENCE=93
SET !VAR1 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR1}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 119;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_125.png CONFIDENCE=93
SET !VAR1 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR1}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 125;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_169.png CONFIDENCE=93
SET !VAR1 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR1}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 169;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_175.png CONFIDENCE=93
SET !VAR1 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR1}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 175;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_219.png CONFIDENCE=93
SET !VAR1 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR1}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 219;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_269.png CONFIDENCE=93
SET !VAR1 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR1}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 269;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_275.png CONFIDENCE=93
SET !VAR1 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR1}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 275;}else{x1 = ix10;}; x1;")

WAIT SECONDS=1
DS CMD=CLICK X=457 Y=366 CONTENT=
WAIT SECONDS=0.3
IMAGESEARCH POS=1 IMAGE=sam_RD_119.png CONFIDENCE=93
SET !VAR2 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR2}}'; var x1; if(ix=='350' || ix=='351' || ix=='352'){x1 = 119;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_125.png CONFIDENCE=93
SET !VAR2 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR2}}'; var x1; if(ix=='350' || ix=='351' || ix=='352'){x1 = 125;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_169.png CONFIDENCE=93
SET !VAR2 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR2}}'; var x1; if(ix=='350' || ix=='351' || ix=='352'){x1 = 169;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_175.png CONFIDENCE=93
SET !VAR2 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR2}}'; var x1; if(ix=='350' || ix=='351' || ix=='352'){x1 = 175;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_219.png CONFIDENCE=93
SET !VAR2 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR2}}'; var x1; if(ix=='350' || ix=='351' || ix=='352'){x1 = 219;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_269.png CONFIDENCE=93
SET !VAR2 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR2}}'; var x1; if(ix=='350' || ix=='351' || ix=='352'){x1 = 269;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_275.png CONFIDENCE=93
SET !VAR2 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR2}}'; var x1; if(ix=='350' || ix=='351' || ix=='352'){x1 = 275;}else{x1 = ix10;}; x1;")


WAIT SECONDS=1
DS CMD=CLICK X=565 Y=296 CONTENT=
WAIT SECONDS=0.3
IMAGESEARCH POS=1 IMAGE=sam_RD_119.png CONFIDENCE=93
SET !VAR3 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR3}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 119;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_125.png CONFIDENCE=93
SET !VAR3 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR3}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 125;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_169.png CONFIDENCE=93
SET !VAR3 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR3}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 169;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_175.png CONFIDENCE=93
SET !VAR1 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR3}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 175;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_219.png CONFIDENCE=93
SET !VAR3 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR3}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 219;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_269.png CONFIDENCE=93
SET !VAR3 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR3}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 269;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_275.png CONFIDENCE=93
SET !VAR3 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR3}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 275;}else{x1 = ix10;}; x1;")

SET !VAR4 0


'AB
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix1==ix2 && ix2==ix3 && ix1!=' ' && ix2!=' ' && ix3!=' '){x1 = 1;} else{x1 = ix10;}; x1;")
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix3>=ix1 && ix1>ix2){x1 = 1;} else{x1 = ix10;}; x1;")
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix3>ix1 && ix1>=ix2){x1 = 1;} else{x1 = ix10;}; x1;")
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix3>ix2 && ix2>=ix1){x1 = 1;} else{x1 = ix10;}; x1;")
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix3>=ix2 && ix2>ix1){x1 = 1;} else{x1 = ix10;}; x1;")
'PROMPT {{!VAR4}}

'BC
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix1>ix2 && ix2>=ix3){x1 = 2;} else{x1 = ix10;}; x1;")
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix1>=ix2 && ix2>ix3){x1 = 2;} else{x1 = ix10;}; x1;")
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix1>=ix3 && ix3>ix2){x1 = 2;} else{x1 = ix10;}; x1;")
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix1>ix3 && ix3>=ix2){x1 = 2;} else{x1 = ix10;}; x1;")
'PROMPT {{!VAR4}}

'AC
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix2>ix1 && ix1>=ix3){x1 = 3;} else{x1 = ix10;}; x1;")
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix2>=ix1 && ix1>ix3){x1 = 3;} else{x1 = ix10;}; x1;")
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix2>=ix3 && ix3>ix1){x1 = 3;} else{x1 = ix10;}; x1;")
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix2>ix3 && ix3>=ix1){x1 = 3;} else{x1 = ix10;}; x1;")
'PROMPT {{!VAR4}}


I tried this
but sometimes the condition it selects is incorrect
like for VAR1 = 219, VAR2 = 169, VAR3 = 169
it gives out VAR4 = 1
instead of 2

mostly i noticed that it gives out wrong output in case two values are same

Well..., I don't know and I'm not going to debug your complete Script, and I told you I don't help for Games anyway... Keep it simple and stick to your original Qt and 'EVAL()' Statement, I'm pretty confident the Statement(s) with the Syntax I gave you is/are correct...

The only "thing" I'm a bit uncertain of is that you reuse '!VAR4' within '!VAR4', I never reuse Vars inside their own 'EVAL()' Statement, so I'm not sure this works, and it depends on the previous Def for that Var...
- (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: 6872
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Nested if-else within EVAL()

by Aditya93 on Wed Jan 10, 2018 7:23 am

chivracq wrote:
Aditya93 wrote:
Code: Select all
WAIT SECONDS=1
DS CMD=CLICK X=283 Y=285 CONTENT=
WAIT SECONDS=0.3
IMAGESEARCH POS=1 IMAGE=sam_RD_119.png CONFIDENCE=93
SET !VAR1 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR1}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 119;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_125.png CONFIDENCE=93
SET !VAR1 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR1}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 125;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_169.png CONFIDENCE=93
SET !VAR1 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR1}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 169;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_175.png CONFIDENCE=93
SET !VAR1 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR1}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 175;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_219.png CONFIDENCE=93
SET !VAR1 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR1}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 219;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_269.png CONFIDENCE=93
SET !VAR1 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR1}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 269;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_275.png CONFIDENCE=93
SET !VAR1 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR1}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 275;}else{x1 = ix10;}; x1;")

WAIT SECONDS=1
DS CMD=CLICK X=457 Y=366 CONTENT=
WAIT SECONDS=0.3
IMAGESEARCH POS=1 IMAGE=sam_RD_119.png CONFIDENCE=93
SET !VAR2 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR2}}'; var x1; if(ix=='350' || ix=='351' || ix=='352'){x1 = 119;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_125.png CONFIDENCE=93
SET !VAR2 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR2}}'; var x1; if(ix=='350' || ix=='351' || ix=='352'){x1 = 125;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_169.png CONFIDENCE=93
SET !VAR2 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR2}}'; var x1; if(ix=='350' || ix=='351' || ix=='352'){x1 = 169;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_175.png CONFIDENCE=93
SET !VAR2 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR2}}'; var x1; if(ix=='350' || ix=='351' || ix=='352'){x1 = 175;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_219.png CONFIDENCE=93
SET !VAR2 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR2}}'; var x1; if(ix=='350' || ix=='351' || ix=='352'){x1 = 219;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_269.png CONFIDENCE=93
SET !VAR2 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR2}}'; var x1; if(ix=='350' || ix=='351' || ix=='352'){x1 = 269;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_275.png CONFIDENCE=93
SET !VAR2 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR2}}'; var x1; if(ix=='350' || ix=='351' || ix=='352'){x1 = 275;}else{x1 = ix10;}; x1;")


WAIT SECONDS=1
DS CMD=CLICK X=565 Y=296 CONTENT=
WAIT SECONDS=0.3
IMAGESEARCH POS=1 IMAGE=sam_RD_119.png CONFIDENCE=93
SET !VAR3 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR3}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 119;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_125.png CONFIDENCE=93
SET !VAR3 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR3}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 125;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_169.png CONFIDENCE=93
SET !VAR3 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR3}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 169;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_175.png CONFIDENCE=93
SET !VAR1 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR3}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 175;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_219.png CONFIDENCE=93
SET !VAR3 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR3}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 219;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_269.png CONFIDENCE=93
SET !VAR3 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR3}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 269;}else{x1 = ix10;}; x1;")
IMAGESEARCH POS=1 IMAGE=sam_RD_275.png CONFIDENCE=93
SET !VAR3 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR3}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 275;}else{x1 = ix10;}; x1;")

SET !VAR4 0


'AB
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix1==ix2 && ix2==ix3 && ix1!=' ' && ix2!=' ' && ix3!=' '){x1 = 1;} else{x1 = ix10;}; x1;")
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix3>=ix1 && ix1>ix2){x1 = 1;} else{x1 = ix10;}; x1;")
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix3>ix1 && ix1>=ix2){x1 = 1;} else{x1 = ix10;}; x1;")
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix3>ix2 && ix2>=ix1){x1 = 1;} else{x1 = ix10;}; x1;")
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix3>=ix2 && ix2>ix1){x1 = 1;} else{x1 = ix10;}; x1;")
'PROMPT {{!VAR4}}

'BC
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix1>ix2 && ix2>=ix3){x1 = 2;} else{x1 = ix10;}; x1;")
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix1>=ix2 && ix2>ix3){x1 = 2;} else{x1 = ix10;}; x1;")
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix1>=ix3 && ix3>ix2){x1 = 2;} else{x1 = ix10;}; x1;")
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix1>ix3 && ix3>=ix2){x1 = 2;} else{x1 = ix10;}; x1;")
'PROMPT {{!VAR4}}

'AC
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix2>ix1 && ix1>=ix3){x1 = 3;} else{x1 = ix10;}; x1;")
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix2>=ix1 && ix1>ix3){x1 = 3;} else{x1 = ix10;}; x1;")
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix2>=ix3 && ix3>ix1){x1 = 3;} else{x1 = ix10;}; x1;")
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix2>ix3 && ix3>=ix1){x1 = 3;} else{x1 = ix10;}; x1;")
'PROMPT {{!VAR4}}


I tried this
but sometimes the condition it selects is incorrect
like for VAR1 = 219, VAR2 = 169, VAR3 = 169
it gives out VAR4 = 1
instead of 2

mostly i noticed that it gives out wrong output in case two values are same

Well..., I don't know and I'm not going to debug your complete Script, and I told you I don't help for Games anyway... Keep it simple and stick to your original Qt and 'EVAL()' Statement, I'm pretty confident the Statement(s) with the Syntax I gave you is/are correct...

The only "thing" I'm a bit uncertain of is that you reuse '!VAR4' within '!VAR4', I never reuse Vars inside their own 'EVAL()' Statement, so I'm not sure this works, and it depends on the previous Def for that Var...





okay but can u tell me
Code: Select all
SET !VAR1 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR1}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 275;}else{x1 = ix10;}; x1;")


and the if else conditions

Code: Select all
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix1==ix2 && ix2==ix3 && ix1!=' ' && ix2!=' ' && ix3!=' '){x1 = 1;} else{x1 = ix10;}; x1;")
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix3>=ix1 && ix1>ix2){x1 = 1;} else{x1 = ix10;}; x1;")


are these correct or something wrong in the syntax of

Code: Select all
if(ix3>=ix1 && ix1>ix2
Aditya93
 
Posts: 39
Joined: Fri Nov 24, 2017 10:34 pm

Re: Nested if-else within EVAL()

by Aditya93 on Wed Jan 10, 2018 8:25 am

Not giving the right output
giving VAR4 as 0


Code: Select all
SET !VAR1 119
'PROMPT {{!VAR1}}
SET !VAR2 150
'PROMPT {{!VAR2}}
SET !VAR3 150
'PROMPT {{!VAR3}}
SET !VAR4 0


'AB
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if((ix3>ix1)&&(ix3>ix2)){x1 = 1;} else{x1 = ix10;}; x1;")
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if((ix1==ix2)&&(ix3>ix1)){x1 = 1;} else{x1 = ix10;}; x1;")
PROMPT {{!VAR4}}

'BC
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if((ix1>ix2)&&(ix1>ix3)){x1 = 2;} else{x1 = ix10;}; x1;")
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if((ix2==ix3)&&(ix1>ix2)){x1 = 2;} else{x1 = ix10;}; x1;")
PROMPT {{!VAR4}}

'AC
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if((ix2>ix1)&&(ix2>ix3)){x1 = 3;} else{x1 = ix10;}; x1;")
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if((ix1==ix3)&&(ix2>ix3)){x1 = 3;} else{x1 = ix10;}; x1;")
PROMPT {{!VAR4}}
Aditya93
 
Posts: 39
Joined: Fri Nov 24, 2017 10:34 pm

Re: Nested if-else within EVAL()

by chivracq on Wed Jan 10, 2018 8:47 am

Aditya93 wrote:okay but can u tell me
Code: Select all
SET !VAR1 EVAL("var ix='{{!IMAGEX}}';var ix10='{{!VAR1}}'; var x1; if(ix=='307' || ix=='308' || ix=='309'){x1 = 275;}else{x1 = ix10;}; x1;")


and the if else conditions

Code: Select all
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix1==ix2 && ix2==ix3 && ix1!=' ' && ix2!=' ' && ix3!=' '){x1 = 1;} else{x1 = ix10;}; x1;")
SET !VAR4 EVAL("var ix1='{{!VAR1}}';var ix2='{{!VAR2}}';var ix3='{{!VAR3}}';var ix10='{{!VAR4}}'; var x1; if(ix3>=ix1 && ix1>ix2){x1 = 1;} else{x1 = ix10;}; x1;")


are these correct or something wrong in the syntax of

Code: Select all
if(ix3>=ix1 && ix1>ix2

You don't need to re-quote yourself if you quote me, that renders the Thread a bit difficult to read...
And you don't really need to quote me either unless you are replying to a specific part of my Reply, or if several Users were posting in the same Thread... I do quote systematically because some Users have a "Tendency" to delete or heavily mutilate their Posts once they've got their Answer to prevent other Users from using their Script, or tend to keep editing their OP or following Posts as they "progress", which then renders such Threads practically useless for other Users searching the Forum... (But I'm Mod on this Forum, and I don't delete my Posts..., I only sometimes correct a Typo afterwards...)

Euh..., but again, those Statements are not the same like in your OP..., first confirm that my Solution works correctly, then if you want to go further, OK, but post a full mini-Script and not a few loose Statements... Like I said, you reuse a '!VAR4' in '!VAR4' itself but I cannot see how it's been defined/declared previously in the Script...

And use the "simplified"/compact Syntax I gave you as your 'EVAL()' Statements are getting more complex, with 'z' for the Result, it's too hard otherwise to follow your Statements with all Inside Vars called 'x'/'x1'/'ix' or 'x_something'... I have some 'EVAL()' Statements in some of my Scripts with more than 100 Conditions in one single 'EVAL()' and they are easy to follow and to debug using this Convention, but I already get lost with your 'EVAL()'s with only a few Conditions as all Vars nearly have the same Names...
- (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: 6872
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Nested if-else within EVAL()

by Aditya93 on Wed Jan 10, 2018 8:47 am

Code: Select all
SET !VAR1 50
'PROMPT {{!VAR1}}
SET !VAR2 90
'PROMPT {{!VAR2}}
SET !VAR3 230
'PROMPT {{!VAR3}}
SET !VAR4 0


when all 3 have the same no of digits the answer is right otherwise it gets wrong
Aditya93
 
Posts: 39
Joined: Fri Nov 24, 2017 10:34 pm

Re: Nested if-else within EVAL()

by Aditya93 on Wed Jan 10, 2018 8:55 am

Euh..., but again, those Statements are not the same like in your OP..., first confirm that my Solution works correctly, then if you want to go further, OK, but post a full mini-Script and not a few loose Statements... Like I said, you reuse a '!VAR4' in '!VAR4' itself but I cannot see how it's been defined/declared previously in the Script...


they were not declared previously anywhere.
and as for the solution that you posted above, no before you posted yours i tried that it didn't work, so while i was looking, found switch, didnt thought it could be used it EVAl():P
but was able to use it and it solved by problem of the if else but not fully as i was comparing the 3 different variable which i got !VAR1, !VAR2, !VAR3 and to check which is the largest and give 1,2,3 output accordingly which isnt going so well

And use the "simplified"/compact Syntax I gave you as your 'EVAL()' Statements are getting more complex, with 'z' for the Result, it's too hard otherwise to follow your Statements with all Inside Vars called 'x'/'x1'/'ix' or 'x_something'... I have some 'EVAL()' Statements in some of my Scripts with more than 100 Conditions in one single 'EVAL()' and they are easy to follow and to debug using this Convention, but I already get lost with your 'EVAL()'s with only a few Conditions as all Vars nearly have the same Names...


yes will change them and post
Aditya93
 
Posts: 39
Joined: Fri Nov 24, 2017 10:34 pm


Return to General Support & Discussions

Who is online

Users browsing this forum: Baidu [Spider] and 3 guests

-->