EasyPattern Error

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

EasyPattern Error

Post by kpassaur » Fri Jul 09, 2010 11:32 am

When an incorrect EasyPattern is entered an error message is displayed when you step through the code. Is there anyway to capture the error message and not have the script display a message?

What I am trying to do is simple, not have to test each EasyPattern to make sure the reserved punctuation is not used incorrectly. This appears to be built in, but how to capture it and let the script run is not in the help file.

I was hoping for something like
Let>Continue_On_Error=YES
Result=It failed because there are no mathing brackets

etc.

Without this it means that I would need to test for each [, ], (, ), , , ', " and make sure there is a matching set or it does not exist.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Jul 09, 2010 12:45 pm

Hi,

Let>IGNOREERRORS=1
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Easy Pattern Brackets

Post by kpassaur » Mon Jul 12, 2010 7:36 am

Thanks Marcus it is just what I needed.

When I was looking to resolve this I wrote this subroutine that looks for matching brackets "[". It maybe usefull to others. It checks to make sure a "[" bracket has a matching closing bracket.

Code: Select all


Let>pattern=This is a pattern:[123]7890-^&*(45)_[123]

Let>text=This is an IP address: 192.168.10.42

GoSub>Test_EP_SUB
Let>IGNOREERRORS=0

If>Test=Passed
RegEx>pattern,text,1,matches,num,0
If>num>0
MessageModal>matches_1
Else
MDL>No Match
Endif
Else
MDL>Cannot apply EasyPattern%CRLF%%CRLF%%MSG_Text%
Endif


SRT>Test_EP_SUB
Let>Test=Passed
Let>x=1
Let>z=1
Let>Match_needed=NO
Label>restart1
Position>[,%pattern%,%x%,tv1
If>Match_needed=NO
If>%tv1%=0
Goto>test_2
Endif
Endif
Let>x=x+tv1
If>tv1>0
Position>],%pattern%,%z%,tv2
Let>z=z+tv2
If>tv2<tv1>Failed_square_Bracket1
Else
Let>Match_needed=YES
Goto>restart1
Endif
Endif
Goto>Have_matching_Brackets1
Label>Failed_square_Bracket1
Let>Test=Failed
Let>MSG_Text=Cannot find matching a matching "]" brackets
Goto>END_OF_TEST_SUB
Label>Have_matching_Brackets1
Label>test_2
Let>x=1
Let>z=1
Let>Match_needed=NO
Label>restart2
Position>],%pattern%,%x%,tv1
If>Match_needed=NO
If>%tv1%=0
Goto>END_OF_TEST_SUB
Endif
Endif
Let>Match_needed=YES
Let>x=x+tv1
If>tv1>0
Position>[,%pattern%,%z%,tv2
If>%tv2%=0
Goto>Failed_square_Bracket2
Endif
Let>z=z+tv2

If>x>z
Let>Match_needed=NO
Goto>restart2
Else
Goto>Failed_square_Bracket2
Endif
Endif
Label>Failed_square_Bracket2
Let>MSG_Text=Cannot find matching a matching "[" brackets
Let>Test=Failed
Goto>END_OF_TEST_SUB
Label>END_OF_TEST_SUB
END>Test_EP_SUB



Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts