How to handle empty input to a int variable?

studio
variable

#1

Hi all!
First post here. Cannot find an answer to my questions so posting the question.

I have an int variable that I created in this “guessing game” example from the manual. If the input is a number everything works as expected but if the input is nothing - that is = null then I get an error message. Which is ok so I need to handle this but it seems that I cant do a “isnothing(intvariable)=true” in a decision activity because the variable itself cannot receive a null-value from the input dialog?

So, my question is, how do you handle this?

Br
Cristian


#2

Hi Christian,

At what point does the error message appear? Is the flow failing when the input is blank or does it then fail when that input is used?

If it is the latter using an if( input = “” OR isnothing(Input) then do something) would work.

If it’s the former you may want to use a try catch around the specific activity to catch that error and handle it that way.

Hope that helps,

Any questions please let me know.

Thanks


#3

Hi,
The flow fails when the input is blank. This is the error message: " Input dialog : Int32Converter cannot convert from (null)." So, my decision is never reached because the failure is in the input dialog. Never tried a “Try catch” - will look into that activity. Thanks for the help.

Br
Cristian


#4

Hi,

Instead can you please check by using

intvariable.Tostring=""

Regards,

Umesh


#5

I would normally solve this by using a String type variable as the input then converting it to a number by variable.Convert.ToInt32 or CInt(variable) when using the value later on in the process
.
so you could have a line similar to this:
If( IsNumeric(variable.Trim), true value, false value )

Or just use the If Condition activities with IsNumeric(variable.Trim).