Nickelgrass Active Member Licensed User Longtime User May 6, 2022 #1 Hello, I have a paradox problem. I have a boolean that sometimes is Null. Code: Copy dim a as boolean a = CallSub2(somemodule, "somefunction", someparameter) If a = Null Then log("a is null") Else Log("not null") If a Then log("a is true") else log("a is false") End If End If Then I get an error "java.lang.RuntimeException: Cannot parse: null as boolean" if it is not null. If I leave away the check "If a = Null then" then I sometimes get the exception that a is null. Do I have to use try catch here? Thanks Regards
Hello, I have a paradox problem. I have a boolean that sometimes is Null. Code: Copy dim a as boolean a = CallSub2(somemodule, "somefunction", someparameter) If a = Null Then log("a is null") Else Log("not null") If a Then log("a is true") else log("a is false") End If End If Then I get an error "java.lang.RuntimeException: Cannot parse: null as boolean" if it is not null. If I leave away the check "If a = Null then" then I sometimes get the exception that a is null. Do I have to use try catch here? Thanks Regards
Solution S S Spavlyuk May 6, 2022 If you want to check for nulls, define a as an object. B4X: Copy Dim A As Object = '... If A <> Null And A.As(Boolean) Then '... End If
If you want to check for nulls, define a as an object. B4X: Copy Dim A As Object = '... If A <> Null And A.As(Boolean) Then '... End If
klaus Expert Licensed User Longtime User May 6, 2022 #2 What does your routine do? CallSub2(somemodule, "somefunction", someparameter) I supect that the return value is not set correctly. Upvote 0
What does your routine do? CallSub2(somemodule, "somefunction", someparameter) I supect that the return value is not set correctly.
S Spavlyuk Active Member Licensed User Longtime User May 6, 2022 #3 If you want to check for nulls, define a as an object. B4X: Copy Dim A As Object = '... If A <> Null And A.As(Boolean) Then '... End If Upvote 1 Solution
If you want to check for nulls, define a as an object. B4X: Copy Dim A As Object = '... If A <> Null And A.As(Boolean) Then '... End If