Hi,
My app transfers data via serial communications, the data is in a string format.
my app seems to run ok but at times it will sometimes throw up and invalid double error, this normally happens if some of the sentances have not been sent and the the fields are blank.
My understanding was if i have a string that contains "00.03" in a variable SomeString
and then i create a variable SomeDouble by:
when i use the following it should convert the string to a double automatically:
is this thinking correct?
what is the outcome if the string contains nothing?
i have tried to catch the error using an if statement to say
basically if the string contains nothing then do not do the conversion, but i still get the error
nothing seems to work
My app transfers data via serial communications, the data is in a string format.
my app seems to run ok but at times it will sometimes throw up and invalid double error, this normally happens if some of the sentances have not been sent and the the fields are blank.
java.lang.NumberFormatException: Invalid double: ""
at java.lang.StringToReal.invalidReal(StringToReal.java:63)
at java.lang.StringToReal.parseDouble(StringToReal.java:248)
at java.lang.Double.parseDouble(Double.java:295)
at android.lishsoft.smids.main._popnmea(main.java:1047)
at android.lishsoft.smids.main._recievetimer_tick(main.java:1233)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:165)
at anywheresoftware.b4a.objects.Timer$TickTack.run(Timer.java:103)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4517)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)
at dalvik.system.NativeStart.main(Native Method)
java.lang.NumberFormatException: Invalid double: ""
My understanding was if i have a string that contains "00.03" in a variable SomeString
and then i create a variable SomeDouble by:
B4X:
Dim SomeDouble as double
when i use the following it should convert the string to a double automatically:
B4X:
SomeDouble = SomeString
is this thinking correct?
what is the outcome if the string contains nothing?
i have tried to catch the error using an if statement to say
B4X:
if SomeString<>"" then SomeDouble=SomeString
nothing seems to work