Conditional Statements in Imacros (not as described in FAQ)

Discussions and Tech Support related to the iMacros Google Chrome extension.

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.

Conditional Statements in Imacros (not as described in FAQ)

by EMPMNSBO7777777 on Wed Jan 24, 2018 1:09 pm

Imacros Version: 8.4.4
Operating System: Windows 10 x64 English
Browser: Google Chrome Version 63.0.3239.132
First, I have read he FAQ, and know that it says EVAL can be used to analyze a certain condition and abort the macro in case this condition is true or false. But, I am trying to see if I can use EVAL to determine if a certain keyword (let's say the text "google.com) is in the address bar/url of the page I'm currently on, and if it doesn't find the text, I would like it to go to a different url (let's say its https://www.google.com/search?ei=aONoWurLAYf1zgLF3IaQAg&q=Just+an+example+url&oq=Just+an+example+url&gs_l=psy-ab.3..33i22i29i30k1l2.437.1225.0.1425.4.4.0.0.0.0.74.251.4.4.0....0...1c.1.64.psy-ab..0.4.250...0j0i22i30k1j0i22i10i30k1.0.ypwqoDaXxq4), and if it does find the text then I would like the script to continue as normal. The difference between what I need and what the FAQ says, is that I don't wont the Macro to be aborted if the condition is false. I have also not finished constructing the actual full Macro that I am using, but I will attach a working sample Macro, that includes the lines I need for this Macro with the example url's I gave above.
Code: Select all
TAB T=1
*To be inserted here: Look for the text "google.com" in the url of the current tab. If "google.com" is in the url, then continue with the Macro. If the textr is not found in the url/address bar, go to the url "[url]https://www.google.com/search?ei=aONoWurLAYf1zgLF3IaQAg&q=Just+an+example+url&oq=Just+an+example+url&gs_l=psy-ab.3..33i22i29i30k1l2.437.1225.0.1425.4.4.0.0.0.0.74.251.4.4.0....0...1c.1.64.psy-ab..0.4.250...0j0i22i30k1j0i22i10i30k1.0.ypwqoDaXxq4[/url]" and continue with the script.*
REFRESH
TAB T=2
*To be inserted here: Look for the text "google.com" in the url of the current tab. If "google.com" is in the url, then continue with the Macro. If the textr is not found in the url/address bar, go to the url "[url]https://www.google.com/search?ei=aONoWurLAYf1zgLF3IaQAg&q=Just+an+example+url&oq=Just+an+example+url&gs_l=psy-ab.3..33i22i29i30k1l2.437.1225.0.1425.4.4.0.0.0.0.74.251.4.4.0....0...1c.1.64.psy-ab..0.4.250...0j0i22i30k1j0i22i10i30k1.0.ypwqoDaXxq4[/url]" and continue with the script.*
REFRESH
TAB T=1

If someone could tell me how to make a script that does this, I would greatly appreciate it.
P.S. I have like zero knowledge of how to use the EVAL tool so If you could just edit the given script, and enter it with the example url and conditions given, I will be able to copy this into my current script and edit it to work for other url's. :mrgreen:
EMPMNSBO7777777
 
Posts: 1
Joined: Wed Jan 24, 2018 12:33 pm

Re: Conditional Statements in Imacros (not as described in F

by chivracq on Wed Jan 24, 2018 1:35 pm

EMPMNSBO7777777 wrote:
Code: Select all
Imacros Version: 8.4.4
Operating System: Windows 10 x64 English
Browser: Google Chrome Version 63.0.3239.132

First, I have read he FAQ, and know that it says EVAL can be used to analyze a certain condition and abort the macro in case this condition is true or false. But, I am trying to see if I can use EVAL to determine if a certain keyword (let's say the text "google.com) is in the address bar/url of the page I'm currently on, and if it doesn't find the text, I would like it to go to a different url (let's say its https://www.google.com/search?ei=aONoWurLAYf1zgLF3IaQAg&q=Just+an+example+url&oq=Just+an+example+url&gs_l=psy-ab.3..33i22i29i30k1l2.437.1225.0.1425.4.4.0.0.0.0.74.251.4.4.0....0...1c.1.64.psy-ab..0.4.250...0j0i22i30k1j0i22i10i30k1.0.ypwqoDaXxq4), and if it does find the text then I would like the script to continue as normal. The difference between what I need and what the FAQ says, is that I don't wont the Macro to be aborted if the condition is false. I have also not finished constructing the actual full Macro that I am using, but I will attach a working sample Macro, that includes the lines I need for this Macro with the example url's I gave above.
Code: Select all
TAB T=1
*To be inserted here: Look for the text "google.com" in the url of the current tab. If "google.com" is in the url, then continue with the Macro. If the textr is not found in the url/address bar, go to the url "[url]https://www.google.com/search?ei=aONoWurLAYf1zgLF3IaQAg&q=Just+an+example+url&oq=Just+an+example+url&gs_l=psy-ab.3..33i22i29i30k1l2.437.1225.0.1425.4.4.0.0.0.0.74.251.4.4.0....0...1c.1.64.psy-ab..0.4.250...0j0i22i30k1j0i22i10i30k1.0.ypwqoDaXxq4[/url]" and continue with the script.*
REFRESH
TAB T=2
*To be inserted here: Look for the text "google.com" in the url of the current tab. If "google.com" is in the url, then continue with the Macro. If the textr is not found in the url/address bar, go to the url "[url]https://www.google.com/search?ei=aONoWurLAYf1zgLF3IaQAg&q=Just+an+example+url&oq=Just+an+example+url&gs_l=psy-ab.3..33i22i29i30k1l2.437.1225.0.1425.4.4.0.0.0.0.74.251.4.4.0....0...1c.1.64.psy-ab..0.4.250...0j0i22i30k1j0i22i10i30k1.0.ypwqoDaXxq4[/url]" and continue with the script.*
REFRESH
TAB T=1

If someone could tell me how to make a script that does this, I would greatly appreciate it.
P.S. I have like zero knowledge of how to use the EVAL tool so If you could just edit the given script, and enter it with the example url and conditions given, I will be able to copy this into my current script and edit it to work for other url's. :mrgreen:

Yep, your Solution in pure '.iim' to work with iMacros for CR (v8.4.4) will use '!URLCURRENT' (if you don't input yourself the URL of your Page) and 'EVAL()' indeed with some JavaScript Command like 'match()' or 'split()' for example to determine if your "google.com" is present in the String of the URL.

Have a look at the following Thread for more Info and where you'll find a List of several relevant Threads with Examples and/or if you search the Forum a bit on my Posts for example, I've already produced more than 100 if not several 100's of 'EVAL()' Examples...:
- Workarounds for Conditional Logic in Macro Code
8)
- (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: 7559
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)


Return to iMacros for Chrome

Who is online

Users browsing this forum: No registered users and 4 guests

-->