If you can't change the source to exclude nulls, then I think you will have to cast the array initially to an array of object to do the conversion, then create the Double array, replacing the nulls as you go.
B4X:
'ObjArr is an array of Object read from the database
Dim DblArr(ObjArr.Length) As Double
For i = 0 To ObjArr.Length - 1
Dim O As Object = ObjArr(i)
If O = Null Then
DblArr(i) = 0
Else
DblArr(i) = O
End If
Next
Sure, it's more universal.
But, it seems that he expects a Double therefore the 'limited' code works.
Because, I hope so, the type check was done before.
Sure, it's more universal.
But, it seems that he expects a Double therefore the 'limited' code works.
Because, I hope so, the type check was done before.
I also normally don't contradict @klaus, but I think this time I disagree with his solution.
If you use this statement str = Curs.GetString2(col) and the value is null str does not become null but sometimes str = "null" as a string, I would do so
B4X:
str = Curs.GetString2(col)
If str <> Null And str<>"null" Then
If isnumber(str) Then
End IF
End IF
I also normally contradict @klaus, but I think this time I disagree with his solution.
If you use this statement str = Curs.GetString2(col) and the value is null str does not become null but sometimes str = "null" as a string, I would do so
B4X:
str = Curs.GetString2(col)
If str <> Null And str<>"null" Then
If isnumber(str) Then
End IF
End IF
B4X short circuits logical evaluations. The first false expression in an and expression stops checking and therefore does not evaluate any other expressions in the statement.
Since the OP retrieves data from a SQLite table, shouldn't he try to avoid the presence of a null in any of his output by simply invoking the Ifnull function like this or am I slow to catch up to this debate: