I am rewriting some code to eliminate use of the jStringFunctions library by using just core functions, but I have hit a snag.
The relevant code is:
and there does not appear to be an equivalent function for the jStringFunctions "Val".
I thought I'd read that it was not necessary to explicitly convert from string to integer and so tried:
but if the relevant character in Text = " ", it throws an exception rather than setting f = 0 as happens when using js.val.
Is there a simpler way than having to detect the special case where the relevant character in Text = " ", eg.:
The relevant code is:
B4X:
Dim f As Int = js.Val(js.mid(Text,2,1))
and there does not appear to be an equivalent function for the jStringFunctions "Val".
I thought I'd read that it was not necessary to explicitly convert from string to integer and so tried:
B4X:
Dim f As Int = Text.substring2(1,2)
but if the relevant character in Text = " ", it throws an exception rather than setting f = 0 as happens when using js.val.
Is there a simpler way than having to detect the special case where the relevant character in Text = " ", eg.:
B4X:
Dim f as Int
If Text.substring2(1,2) = " " Then
f = 0
Else
f = Text.substring2(1,2)
End If