If Then problem......again

Discussions and Tech Support related to the iMacros Firefox Add-on, including the built-in Javascript scripting interface for playing .js files.
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
wrznet
Posts: 2
Joined: Sat Oct 26, 2013 11:47 am

If Then problem......again

Post by wrznet » Sat Oct 26, 2013 3:11 pm

As many others here, I run into simple trouble how to use the IF...Then combination. I learned that I can use javascript within EVAL. My puzzle is following.
On page, there is 'Add to your favorites' script code, which is need to be clicked IF exists. When clicked,its changed on the page into '
Added'.
Now I tried to create something like that:

SET EXTRACT NULL
TAG POS=1 TYPE=SPAN ATTR=TXT:Add<SP>to<SP>your<SP>favourites EXTRACT=TXT
SET !VAR1 EVAL(var s=\"{{!EXTRACT}}\"; if(text=="to your favourites") text = "blablabla";else text = "to your favourites";text;)
TAG POS=1 TYPE=SPAN ATTR=TXT:{{!VAR1}}

But it does not work....where I made an error? Sorry, Im newbie yet :)
User avatar
bobis
Posts: 364
Joined: Sat Sep 11, 2010 3:34 pm
Contact:

Re: If Then problem......again

Post by bobis » Sun Oct 27, 2013 6:20 am

try this

Code: Select all

SET !VAR1 EVAL(var s=\"{{!EXTRACT}}\"; var text; if(text==\"to your favourites\") {text = \"blablabla\";}else {text = \"to your favourites\";}text;)
Get Best iMacros scripts at http://imacrosbot.com/
wrznet
Posts: 2
Joined: Sat Oct 26, 2013 11:47 am

Re: If Then problem......again

Post by wrznet » Sun Oct 27, 2013 5:57 pm

Thanks for your help. I tried to change the line to yours, but still the problem exist.

VERSION BUILD=8510617 RECORDER=FX
TAB T=1
SET !ERRORIGNORE YES
SET EXTRACT NULL
TAG POS=1 TYPE=SPAN ATTR=TXT:Add<SP>to<SP>your<SP>favourites EXTRACT=TXT
SET !VAR1 EVAL(var s=\"{{!EXTRACT}}\"; var text; if(text==\"to your favourites\") {text = \"blablabla\";}else {text = \"to your favourites\";}text;)
TAG POS=1 TYPE=SPAN ATTR=TXT:{{!VAR1}}

'Add to your favourites' not clicked, instead error:

SyntaxError: wrong format of SET command, line: 6 (Error code: -910)
chivracq
Posts: 8716
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: If Then problem......again

Post by chivracq » Mon Oct 28, 2013 2:02 am

If I understand your problem correctly, you could just simply always (try to) click on the 'Add' Button with "SET !ERRORIGNORE YES".
If the 'Add' Button is not present, you just lose a few seconds (set by TIMEOUT_STEP)...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
User avatar
bobis
Posts: 364
Joined: Sat Sep 11, 2010 3:34 pm
Contact:

Re: If Then problem......again

Post by bobis » Mon Oct 28, 2013 6:33 am

here is fixed code

Code: Select all

SET !VAR1 EVAL("var s=\"{{!EXTRACT}}\"; if(s == \"to your favourites\"){text = \"blablabla\";}else {text = \"to your favourites\";}text;")
Get Best iMacros scripts at http://imacrosbot.com/
Post Reply