How to Search Repeating Numbers eg. 222

Discussions and Tech Support related to automating the iMacros Browser or Internet Explorer from any scripting and programming language, such as VBS (WSH), VBA, VB, Perl, Delphi, C# or C++.
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
whitez
Posts: 5
Joined: Tue Aug 30, 2011 12:47 am

How to Search Repeating Numbers eg. 222

Post by whitez » Tue Aug 30, 2011 12:53 am

Hi Guys,

I'm trying to create a script for firefox.
How do you stop a script if it finds three of the same number (222) in a row at Line 2?


Line 1: John Smith
Line 2: 92227893
Line 3: 15 George St, NY 21457

Thanks.
Last edited by whitez on Thu Sep 22, 2011 3:06 am, edited 1 time in total.
Daniel, Tech Support
Posts: 1483
Joined: Tue Jan 26, 2010 11:35 am

Re: How to Stop if Found something

Post by Daniel, Tech Support » Fri Sep 02, 2011 9:35 am

Hi,

If its always "2", then you could use EVENT:FAIL_IF_FOUND e.g. like this:

Code: Select all

TAG POS=1 TYPE=DIV ATTR=TXT:*222* CONTENT=EVENT:FAIL_IF_FOUND
However if it could be any digit, you would need to extract the whole line and then use Web Scripting to process it.

Best regards,
Daniel, iOpus Support
whitez
Posts: 5
Joined: Tue Aug 30, 2011 12:47 am

Re: How to Stop if Found something

Post by whitez » Mon Sep 05, 2011 11:41 pm

Thanks for this.
Any chance you can list the whole script as I'm not familiar with the whole scripting?
Daniel, Tech Support
Posts: 1483
Joined: Tue Jan 26, 2010 11:35 am

Re: How to Stop if Found something

Post by Daniel, Tech Support » Tue Sep 06, 2011 3:42 pm

Hi,

I would gladly help you to create the script, but naturally I would need more info, i.e. "is it always 2 or can it be any digit", what is the URL of the website you're trying to automate etc.

Best regards,
Daniel, iOpus Support
whitez
Posts: 5
Joined: Tue Aug 30, 2011 12:47 am

Re: How to Stop if Found something

Post by whitez » Wed Sep 07, 2011 6:07 am

Hi Daniel,

It will be for any digit as long as they appear 3 times in a row eg. 222, 555 or 777.
Thanks
Daniel, Tech Support
Posts: 1483
Joined: Tue Jan 26, 2010 11:35 am

Re: How to Stop if Found something

Post by Daniel, Tech Support » Thu Sep 08, 2011 3:28 pm

Hi,

What about the URL or at least the TAG command you use to extract the 2nd line? I can also create a generic script, which you would then need to adjust. Tell me if you prefer that.

Best regards,
Daniel, iOpus Support
whitez
Posts: 5
Joined: Tue Aug 30, 2011 12:47 am

Re: How to Stop if Found something

Post by whitez » Thu Sep 08, 2011 10:51 pm

Hi Daniel,

Sorry I don't understand tag command but I include my current macro that works for me.
So your new "stop" command should be replacing "WAIT SECONDS=2.5"
Is this enough for you?
Thanks

Code: Select all

VERSION BUILD=7300701 RECORDER=FX
TAG POS=1 TYPE=IMG ATTR=BORDER:0&&SRC:/web/ShowBinary/SCSRepository/assets/images/formButtons/btn_next.gif&&ILO-FULL-SRC:https://personal.***.com/web/ShowBinary/SCSRepository/assets/images/formButtons/btn_next.gif&&TXT:
WAIT SECONDS=2.5
TAG POS=1 TYPE=IMG ATTR=BORDER:0&&SRC:/web/ShowBinary/SCSRepository/assets/images/formButtons/btn_back.gif&&ILO-FULL-SRC:https://personal.***.com/web/ShowBinary/SCSRepository/assets/images/formButtons/btn_back.gif&&TXT:
Daniel, Tech Support
Posts: 1483
Joined: Tue Jan 26, 2010 11:35 am

Re: How to Stop if Found something

Post by Daniel, Tech Support » Tue Sep 13, 2011 11:11 am

Hi,

I'm sorry, but I need to know what to extract.. Can you record a click on the text that needs to be extracted and send me the recorded macro please?

Best wishes,
Daniel, iOpus Support
MattBell7
Posts: 627
Joined: Thu Nov 26, 2009 11:07 am
Location: United Kingdom

Re: How to Stop if Found something

Post by MattBell7 » Tue Sep 13, 2011 12:14 pm

SEARCH SOURCE=REGEXP:".*(([0-9])\\2\\2).*" EXTRACT=$1
TAG POS=1 TYPE=* ATTR=TXT:*{{!EXTRACT}}* CONTENT=EVENT:FAIL_IF_FOUND

you can use something like the above, but it doesn't work if the page source has 3 consecutive numbers in it.

the first line searches for the 3 numbers, the second checks if it is on the main page and throws the error.
whitez
Posts: 5
Joined: Tue Aug 30, 2011 12:47 am

Re: How to Stop if Found something

Post by whitez » Wed Sep 21, 2011 2:54 am

tried to use this but doesn't seem to work.

Code: Select all

SEARCH SOURCE=REGEXP:".*(([0-9])\\2\\2).*" EXTRACT=$1
TAG POS=1 TYPE=* ATTR=TXT:*{{!EXTRACT}}* CONTENT=EVENT:FAIL_IF_FOUND
so this is what I use at the moment, but its kinda slow because it needs to pause around 1 second between TAG POS.
Is there another way to make the seach quicker?
Thanks

Code: Select all

VERSION BUILD=7300701 RECORDER=FX
TAG POS=1 TYPE=IMG ATTR=BORDER:0&&SRC:/web/ShowBinary/SCSRepository/assets/images/formButtons/btn_next.gif&&ILO-FULL-SRC:https://something.com/web/ShowBinary/SCSRepository/assets/images/formButtons/btn_next.gif&&TXT:
SET !TIMEOUT_STEP 0
TAG POS=1 TYPE=DIV ATTR=TXT:*000* CONTENT=EVENT:FAIL_IF_FOUND
TAG POS=1 TYPE=DIV ATTR=TXT:*111* CONTENT=EVENT:FAIL_IF_FOUND
TAG POS=1 TYPE=DIV ATTR=TXT:*222* CONTENT=EVENT:FAIL_IF_FOUND
TAG POS=1 TYPE=DIV ATTR=TXT:*333* CONTENT=EVENT:FAIL_IF_FOUND
TAG POS=1 TYPE=DIV ATTR=TXT:*444* CONTENT=EVENT:FAIL_IF_FOUND
TAG POS=1 TYPE=DIV ATTR=TXT:*555* CONTENT=EVENT:FAIL_IF_FOUND
TAG POS=1 TYPE=DIV ATTR=TXT:*666* CONTENT=EVENT:FAIL_IF_FOUND
TAG POS=1 TYPE=DIV ATTR=TXT:*777* CONTENT=EVENT:FAIL_IF_FOUND
TAG POS=1 TYPE=DIV ATTR=TXT:*888* CONTENT=EVENT:FAIL_IF_FOUND
TAG POS=1 TYPE=DIV ATTR=TXT:*999* CONTENT=EVENT:FAIL_IF_FOUND
TAG POS=1 TYPE=IMG ATTR=BORDER:0&&SRC:/web/ShowBinary/SCSRepository/assets/images/formButtons/btn_back.gif&&ILO-FULL-SRC:https://something.com/web/ShowBinary/SCSRepository/assets/images/formButtons/btn_back.gif&&TXT:
Daniel, Tech Support
Posts: 1483
Joined: Tue Jan 26, 2010 11:35 am

Re: How to Search Repeating Numbers eg. 222

Post by Daniel, Tech Support » Tue Oct 11, 2011 10:01 pm

Hi,

I'm very sorry for the super delayed response! If you have a version of iMacros that supports Web Scripting, then you can easily extract the value you want to check with:

Code: Select all

TAG POS=1 TYPE=DIV ATTR=TXT:*000* EXTRACT=TXT
and then check if the value matches 3 digits.

Here is an example for Firefox and JavaScript:

Code: Select all

var macro = "TAG POS=1 TYPE=DIV ATTR=TXT:*000* EXTRACT=TXT\n";

var iret = iimPlay("CODE:" + macro);
var str = iimGetLastExtract();

//Check the str value here
Best regards,
Daniel, iOpus Support
Daniel, Tech Support
Posts: 1483
Joined: Tue Jan 26, 2010 11:35 am

Re: How to Search Repeating Numbers eg. 222

Post by Daniel, Tech Support » Tue Oct 11, 2011 10:04 pm

Please do let me know if you need further help!
Daniel, iOpus Support
Bicgatepc02
Posts: 3
Joined: Sat Jan 19, 2013 10:27 am

Re: How to Search Repeating Numbers eg. 222

Post by Bicgatepc02 » Tue Jan 22, 2013 5:25 am

Great, but as I'm not good at javascript I would just like to see "random" as a native command in Imacros script, but this javascript code will solve my problem.
I suggest something like :

SET !RANDOM=100 (just like TIMEOUT)

Then someone can use RANDOM word everywhere and it will choose a number between 0-100

Anyway thanks :D
Tom, Tech Support
Posts: 3601
Joined: Mon May 31, 2010 4:59 pm

Re: How to Search Repeating Numbers eg. 222

Post by Tom, Tech Support » Wed Jan 23, 2013 9:14 am

Hi Bicgatepc02,

You can use the EVAL command to generate random values in your macro. There's even a Random Wait example already provided.
Regards,

Tom, iMacros Support
Post Reply