EVAL if else error in iMacros

Discussions and Tech Support specific to the iMacros Firefox add-on.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

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
asder
Posts: 2
Joined: Sun Oct 22, 2017 5:36 am

EVAL if else error in iMacros

Post by asder » Sun Oct 22, 2017 6:14 am

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}}
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: EVAL if else error in iMacros

Post by chivracq » Sun Oct 22, 2017 7: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)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
asder
Posts: 2
Joined: Sun Oct 22, 2017 5:36 am

Re: EVAL if else error in iMacros

Post by asder » Sun Oct 22, 2017 11:36 am

Thank you for your response, I have working code now
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: EVAL if else error in iMacros

Post by chivracq » Mon Oct 23, 2017 1:38 pm

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)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Post Reply