ELSE IF statement with iMacros

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 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
hipeq
Posts: 1
Joined: Wed May 23, 2018 10:15 am

ELSE IF statement with iMacros

Post by hipeq » Wed May 23, 2018 10:21 am

Hi,

Im trying to compare some values from variables with value from extraction to click something

First block:

Code: Select all

SET !VAR2 EVAL("var text1=\"{{!EXTRACT}}\"; if(text1==\"{{!VAR6}}\") {text1 = \"tr_answer1\";} else if(text1==\"{{!VAR7}}\") {text1 = \"tr_answer2\";} else if(text1==\"{{!VAR8}}\") {text1 = \"tr_answer3\";} else text1 = \"tr_answer4\";text1;")

and after:

Code: Select all

TAG POS=1 TYPE=TR ATTR=ID:{{!VAR2}}
VAR2 should return one of values like tr_answer1 or others. But it not works correctly. It always return tr_answer4 from ELSE statement.

Someone knows what im doing wrong? It's possible to do it like this? I can't find syntax of correct else if statement with JS in iMacros.

Im sure that one of values from variables is equal to extracted value

I have not found answer with search
chivracq
Posts: 8525
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: ELSE IF statement with iMacros

Post by chivracq » Wed May 23, 2018 4:51 pm

hipeq wrote:Hi,

Im trying to compare some values from variables with value from extraction to click something

First block:

Code: Select all

SET !VAR2 EVAL("var text1=\"{{!EXTRACT}}\"; if(text1==\"{{!VAR6}}\") {text1 = \"tr_answer1\";} else if(text1==\"{{!VAR7}}\") {text1 = \"tr_answer2\";} else if(text1==\"{{!VAR8}}\") {text1 = \"tr_answer3\";} else text1 = \"tr_answer4\";text1;")
and after:

Code: Select all

TAG POS=1 TYPE=TR ATTR=ID:{{!VAR2}}
VAR2 should return one of values like tr_answer1 or others. But it not works correctly. It always return tr_answer4 from ELSE statement.

Someone knows what im doing wrong? It's possible to do it like this? I can't find syntax of correct else if statement with JS in iMacros.

Im sure that one of values from variables is equal to extracted value

I have not found answer with search
Oh...!, nice to see that you've discovered "our" Forum as well, ah-ah...! ... But the "Rules" (that you forgot to read, oops...!) are a little bit "stricter" here than on SOF, if you want some Answer/Help, at least from me... :wink:
=> CIM...! :mrgreen: (Read my Sig...)

Hum..., and of course you don't need to kind of spam the Forum by opening directly several Duplicates of your Thread...!, one is enough...! :roll:

(The Solution to your Pb is (probably) very simple I think, if that can "motivate" you to mention your FCI correctly... :wink: )
=> Answer is YES + YES to your 2 Qt's, ah-ah...!
- (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...
Post Reply