Action Based on Found Text

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Jlomers
Newbie
Posts: 7
Joined: Tue Feb 06, 2018 4:11 pm

Action Based on Found Text

Post by Jlomers » Tue Feb 06, 2018 4:56 pm

I am hoping someone can help me understand something.

I have a script that grabs text from the screen and returns something like this
__
Balance

33.
39.
35.
204.
0.
33.
185.
286.
169.
__

I want to be able to take an action based on the line being a number greater than zero. So in this case it would take the action for all 3-6 and 8-11. but not 7 because it is zero. My thought is to turn the text into an array and then test each line of the array. However, I am not sure how I can turn the OCRed data into an array or if there is some better way to manage this task.

Any help?

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

Re: Action Based on Found Text

Post by Marcus Tettmar » Mon Feb 12, 2018 3:24 pm

Use the RegEx or Separate functions.

Here's an example. For the purposes of a working example I've hard coded the data to a label in place of where you'd get it from the screen:

Code: Select all

/*
Data:
Balance
33.
39.
35.
204.
0.
33.
185.
286.
169.
__

*/

LabelToVar>Data,strData
RegEx>\d*(?=\.),strData,0,matches,nm,0
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

Jlomers
Newbie
Posts: 7
Joined: Tue Feb 06, 2018 4:11 pm

Re: Action Based on Found Text

Post by Jlomers » Mon Feb 12, 2018 3:26 pm

Thank you Marcus, I found the same answer this weekend.

I had to learn what regular expressions were to use the regex command.

This pulled the data into an array and I could take action off the Array_1 - Array_x separately.

Regexr.com is a great learning tool I found. I believe it was referenced in a blog post by Marcus but the link didn't work any longer as I think it was separated into a standalone page after he wrote about it.

Just wanted to close the loop and add Regexr.com incase anyone had a similar question that might come up in a future search.

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