HOW TO iMacro If Else Statement without Javascript?

Discussions and Tech Support specific to the iMacros Firefox add-on.
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
chen55
Posts: 16
Joined: Wed Sep 27, 2017 9:17 am

HOW TO iMacro If Else Statement without Javascript?

Post by chen55 » Wed Sep 27, 2017 9:27 am

I currently make a iMacro script that use EXTRACT to find the TAG

Code: Select all

VERSION BUILD=9030808 RECORDER=FX
SET !ERRORIGNORE YES
TAB T=1
TAG POS=1 TYPE=I ATTR=CLASS:icon-pencil&&TXT: EXTRACT=HTM

SET !VAR10 EVAL("var s='{{!EXTRACT}}'; if(s=='<i class=\"icon-pencil\" style=\"outline: 1px solid blue;\"></i>'){s='imacros://run/?m=ADD.iim';} else {s='imacros://run/?m=A.iim';}; s;")
URL GOTO={{!VAR10}}

How can I make the if statement ?
chivracq
Posts: 9318
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: HOW TO iMacro If Else Statement without Javascript?

Post by chivracq » Wed Sep 27, 2017 11:00 am

chen55 wrote:I currently make a iMacro script that use EXTRACT to find the TAG

Code: Select all

VERSION BUILD=9030808 RECORDER=FX
SET !ERRORIGNORE YES
TAB T=1
TAG POS=1 TYPE=I ATTR=CLASS:icon-pencil&&TXT: EXTRACT=HTM

SET !VAR10 EVAL("var s='{{!EXTRACT}}'; if(s=='<i class=\"icon-pencil\" style=\"outline: 1px solid blue;\"></i>'){s='imacros://run/?m=ADD.iim';} else {s='imacros://run/?m=A.iim';}; s;")
URL GOTO={{!VAR10}}
How can I make the if statement ?
FCIM...! :mrgreen: (Read my Sig...)
=> iMacros for FF v9.0.3, FF55/56...?, OS...?

But yep, I don't think you can call the next Macro directly from within the 'EVAL()' Statement, but you can compute the String corresponding to the Macro Name for example to reuse in the 'URL GOTO' like:

Code: Select all

URL GOTO=imacros://run/?m={{!VAR10}}.iim
Euh...!, are you sure btw that '!VAR10' exists...!? Wiki says '!VARn' with n=[0-9]...

But, hum..., you might have to revert to v8.9.7 for FF, I think the 'imacros://run/?m=' Syntax is not supported anymore in v9.0.3... (v8.9.7 for FF still works in FF v55.0.3, I didn't have a chance to test yet in FF56...)

EDIT: :oops:
Ah but oops...!, that's what you were already doing with the String to reuse in 'URL GOTO', ah-ah...! (I'm not completely awake yet...! :oops: )
Then you are hitting the Limitation I mentioned about v9.0.3, I reckon...
- (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...
chen55
Posts: 16
Joined: Wed Sep 27, 2017 9:17 am

Re: HOW TO iMacro If Else Statement without Javascript?

Post by chen55 » Wed Sep 27, 2017 11:51 am

thank chivracq
I need run TEST1.iim if found class icon-pencil or TEST2.iim if don't fount
please check my code

Code: Select all

VERSION BUILD=9030808 RECORDER=FX
SET !ERRORIGNORE YES
TAB T=1

TAG POS=1 TYPE=I ATTR=CLASS:icon-pencil&&TXT: EXTRACT=HTM

SET !VAR1 EVAL("var s='{{!EXTRACT}}'; if(s=='<i class=\"icon-pencil\" "></i>'){s='TEST1';} else {s='TEST2';}; s;")

URL GOTO=imacros://run/?m={{!VAR1}}.iim

chivracq
Posts: 9318
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: HOW TO iMacro If Else Statement without Javascript?

Post by chivracq » Wed Sep 27, 2017 12:19 pm

chen55 wrote:thank chivracq
I need run TEST1.iim if found class icon-pencil or TEST2.iim if don't fount
please check my code

Code: Select all

VERSION BUILD=9030808 RECORDER=FX
SET !ERRORIGNORE YES
TAB T=1

TAG POS=1 TYPE=I ATTR=CLASS:icon-pencil&&TXT: EXTRACT=HTM

SET !VAR1 EVAL("var s='{{!EXTRACT}}'; if(s=='<i class=\"icon-pencil\" "></i>'){s='TEST1';} else {s='TEST2';}; s;")

URL GOTO=imacros://run/?m={{!VAR1}}.iim
Yeah but sorry, "FCIM" again for me to follow up... :idea:
- (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...
Post Reply