How to tell if a line is empty

Hi

I’m doing a “Get full text” option on a certain line in a box. If the line contains a certain word, it’ll do a certain thing. The issue I’m having is if the line is empty.

I’ve tried Line.Length=0, Line=“”, Line.Contains(“”), however none are working.

I’ve done the screen scraping method out of curiosity to see if it picks anything up, which brings up “AUTOMATIC method failed to scrape this UI Element”

Is there a way I can write something where it’ll tell me if the line is blank?

Any help would be greatly appreciated.

Thanks

1 Like

Hi,

Have you tried String.IsNullOrEmpty(yourVariable) and String.IsNullOrWhitespace(yourVariable)? These are my go-to’s in these situations.

Regards.

2 Likes

Hi @Short,

I recommend you to do the following to be sure that you will get the expected result:

String.IsNullOrEmpty(Convert.ToString(Line).Trim())

Maybe your string has blank spaces and it may be impacting in your conditional statements, so the Trim() function will help you with that.

Hope this helps you!

Best regards,

Bruno Costa.

2 Likes

Hi @andrzej.kniola and @brunoazev

Thanks for your responses! Neither of them worked until I put a space in the line I wanted to read, then they worked, so all sorted now.

Thank you again :slight_smile:

Capture

I still get the error “Index was outside the bounds of the array.”

Sorry, solved it! Using Array.Last in an assign activity and then pass it to the if statement