I'm not clear on the difference between testing an object for NULL vs. using isInitialized.
I ran into this because I passed a Null value into a sub, but it crashed on an "object not initialized" error. Here's the code:
It works fine if I replace the IF with this:
Why doesn't the first version work? Because a Null passed as an argument isn't actually initialized?
I ran into this because I passed a Null value into a sub, but it crashed on an "object not initialized" error. Here's the code:
B4X:
tip1.addTipForArea(tempRect, Null, "foobar", "barfoo")
Public Sub addTipForArea(rectArg As Rect, svArg As ScrollView, titleArg As String, descArg As String)
...some code here
If svArg <> Null Then
rectArg.top = rectArg.Top + svArg.Top
rectArg.Bottom = rectArg.Bottom + svArg.top
End If
...more code here
End Sub
It works fine if I replace the IF with this:
B4X:
If (svArg.IsInitialized) And (svArg <> Null) Then
Why doesn't the first version work? Because a Null passed as an argument isn't actually initialized?