How do I configure the if-else statement for when the OCR captures null values?

I have a sequence that reads through files in a folder. Each of this file will go through Microsoft OCR. If files.Contains(“chicken”), print Message1. Else, print Message2.

However, if the files submitted are maybe zoomed in too much, the OCR cannot capture the correct area which contains the value. I get an error saying ArgumentNullException. How can I prevent UIPath from completely aborting the whole sequence just because of this one file.

U can use try catch activitiy for catching the exception and do Accordingly

@sundalpathyREBORN
before checking the content with contains the variable could be checked first if it is null / empty

isNothing(YourVariable) OrElse String.IsNullOrWhitespace(YourVariable)

The try/catch block will help for not running into an unhandled exception. But deriving a particular meaning from the existence of an exception shpould be avoided if it is possible

1 Like

thank you for the response. May I know what String.IsNullOrWhitespace(YourVariable) do

hi thank you so much for your help i need to know how could i read multiple jpg file in ocr using for each loop and what variable type should i declare

hi are you looping pdf file or jpg file ?

statement checks if a string is null, empty (“”) or whitspace (" "). We can use it for checks as mentioned above. Have a look here:

grafik

jpg.

oh i see, thats great.

my issue must be that there are other activities with dependencies on the OCR. Thus if the OCR reads null, it affects the other activities

thank you so much for your reply can i know how could loop jpg file because i am new in uipath please help me out