EVAL if else error in iMacros

Discussions and Tech Support related to the iMacros Firefox Add-on, including the built-in Javascript scripting interface for playing .js files.

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.

EVAL if else error in iMacros

by asder on Sat Oct 21, 2017 11:14 pm

Hi,

I'm trying to create a macro that will click a button if a certain user's username is not shown on the page, and if that users name is on the page, to move to the next url.

I've looked at other forums about how this could be done, and the code below is the best that I've got. When I play it I get an #EANF# error, and I'm not sure what to change to make it work.

I'm also not entirely sure if the code I've got is the best way of doing want I want either, so I'm open to changing it completely if need be.

iMacros version 8.9.7
Firefox 49.0.2
OS X Yosemite 10.10.5

Code: Select all
SET URL_ID 1234
ADD URL_ID -1{{!LOOP}}
SET !EXTRACT NULL
TAG POS=1 TYPE=BODY ATTR=TXT:user EXTRACT=TXT
SET !VAR1 EVAL("var text=\"{{!EXTRACT}}\"; if(text==\"user\") text=\"jibber\"; else text=\"click me\";text;")
TAG POS=1 TYPE=BUTTON ATTR=TXT:{{!VAR1}}
WAIT SECONDS=0.5
URL GOTO=https://abcd.com/{{URL_ID}}
asder
 
Posts: 2
Joined: Sat Oct 21, 2017 10:36 pm

Re: EVAL if else error in iMacros

by chivracq on Sun Oct 22, 2017 12:11 am

asder wrote:
Code: Select all
iMacros version 8.9.7
Firefox 49.0.2
OS X Yosemite 10.10.5


Hi,

I'm trying to create a macro that will click a button if a certain user's username is not shown on the page, and if that users name is on the page, to move to the next url.

I've looked at other forums about how this could be done, and the code below is the best that I've got. When I play it I get an #EANF# error, and I'm not sure what to change to make it work.

I'm also not entirely sure if the code I've got is the best way of doing want I want either, so I'm open to changing it completely if need be.

iMacros version 8.9.7
Firefox 49.0.2
OS X Yosemite 10.10.5

Code: Select all
SET URL_ID 1234
ADD URL_ID -1{{!LOOP}}
SET !EXTRACT NULL
TAG POS=1 TYPE=BODY ATTR=TXT:user EXTRACT=TXT
SET !VAR1 EVAL("var text=\"{{!EXTRACT}}\"; if(text==\"user\") text=\"jibber\"; else text=\"click me\";text;")
TAG POS=1 TYPE=BUTTON ATTR=TXT:{{!VAR1}}
WAIT SECONDS=0.5
URL GOTO=https://abcd.com/{{URL_ID}}

FYI: iMacros for FF v8.9.7 still works on FF v55.0.3... I didn't have a chance to test later FF Versions...

But hum..., a somewhat easier Solution for your Scenario would simply be to spit out a "1"/"0" to reuse for the 'POS=n' or maybe even with 'POS=R{{!VAR1}}' using Relative Positioning, 'POS=0" or 'POS=R0' won't do anything..., together with '!ERRORIGNORE' of course...
- (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: 6490
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: EVAL if else error in iMacros

by asder on Sun Oct 22, 2017 4:36 am

Thank you for your response, I have working code now
asder
 
Posts: 2
Joined: Sat Oct 21, 2017 10:36 pm

Re: EVAL if else error in iMacros

by chivracq on Mon Oct 23, 2017 6:38 am

asder wrote:Thank you for your response, I have working code now

Ah OK, good to hear... :D
Would be nice and maybe useful for other Users with a similar Case/Scenario if you could share your final working Script... :D
- (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: 6490
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)


Return to iMacros for Firefox

Who is online

Users browsing this forum: jinjinda and 7 guests

-->