12-01-24 09:15 PM
I am using Recognize Text on an application to read a few columns. These are identified as List Region's. The text is coming back fine - but my problem is when it gets past the bottom/end of the list. I am not sure how to detect I hit the end.
The application does not have any indication of how many rows are available. There could be 10 rows, could be 1000. I am searching for a specific entry in the list - if it finds it, it will double-click on the entry so it can go to the next step. If it does not find the entry, it will throw an exception saying it did not find the entry.
If there are more than 26 items returned, I do have a check in place. I am incrementing the Element - so when it gets to 26, I know the table is showing max rows. It then presses the cursor down, reads row 26, etc. I am checking to see if it has duplicate values. If yes, down arrow did not do anything to the screen and I am at the bottom.
If there are only 10 (anything less than 26), I'm kind of scratching my head over how to detect the bottom. Recognize text will come back with junk data. One though - I can see if the data is alpha-numeric? If yes, I probably have data. If not, I likely went past the bottom of the table.
Any thoughts on this?
15-01-24 12:11 PM
Hi Chris,
On the last question: Depending on what the 'junk data' looks like that you get back, you could check if some letters are present. Even words that should be there can be checked. Obviously, if the 'junk data' is a mixture that also contains letter, this does not work. Unfortunately, while we have functions for IsNumber()
and IsDate()
, no function IsAlphaNumeric()
exists.
Happy coding!
Paul
Sweden
16-01-24 02:00 PM
For the application I am working with, I am using the Utilities - String business object, Test Regex Match. I am using this regex:
"[a-zA-Z0-9]+"
The application I am using seems to consistently return data like this when it is past the table:
Since those characters do not match the regex, it comes back as false. I then have a check to see if it is true/false. If false, I am assuming I am past the bottom of the table I am using recognize text one. I then throw an exception so I know what happened. In my case, it means it did not find what it was looking for in the table and it was past the bottom of the list.
16-01-24 04:23 PM
Hi Chris - one option is to capture an image of the cell you're reading and test if it contains only the background colour (implying the cell is empty and you've gone past the last row). This is an awkward technique however, because you have to accurately move the region down row by row. I haven't checked in a while but I don't think the List Region provides a 'get images' option, so you'd need a second region that dynamically moves downwards. As I said, awkward.