imgsimonebiliato Well-Known Member Licensed User Longtime User Jun 23, 2016 #1 Hello, I created a map and I populated it like this: Code: map.Put("2016062309343853.jpg", "c:\desktop") When I want to retrieve the key value, i do this Code: Dim i as int i = 0 map.GetKeyAt(i) but I get this error log: Code: java.lang.NumberFormatException: Invalid double: "2016062309343853.jpg" at java.lang.StringToReal.invalidReal(StringToReal.java:63) at java.lang.StringToReal.parseDouble(StringToReal.java:269) at java.lang.Double.parseDouble(Double.java:295) at it.android.imgspa.and_FotoContainer.svcupload._smb1_listcompleted(svcupload.java:409) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175) at anywheresoftware.b4a.BA$3.run(BA.java:320) at android.os.Handler.handleCallback(Handler.java:725) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:153) at android.app.ActivityThread.main(ActivityThread.java:5297) 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:833) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) at dalvik.system.NativeStart.main(Native Method) I read that: The key should be a string or a number. The value can be any type of object. Click to expand... So what's wrong?
Hello, I created a map and I populated it like this: Code: map.Put("2016062309343853.jpg", "c:\desktop") When I want to retrieve the key value, i do this Code: Dim i as int i = 0 map.GetKeyAt(i) but I get this error log: Code: java.lang.NumberFormatException: Invalid double: "2016062309343853.jpg" at java.lang.StringToReal.invalidReal(StringToReal.java:63) at java.lang.StringToReal.parseDouble(StringToReal.java:269) at java.lang.Double.parseDouble(Double.java:295) at it.android.imgspa.and_FotoContainer.svcupload._smb1_listcompleted(svcupload.java:409) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175) at anywheresoftware.b4a.BA$3.run(BA.java:320) at android.os.Handler.handleCallback(Handler.java:725) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:153) at android.app.ActivityThread.main(ActivityThread.java:5297) 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:833) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) at dalvik.system.NativeStart.main(Native Method) I read that: The key should be a string or a number. The value can be any type of object. Click to expand... So what's wrong?
eurojam Well-Known Member Licensed User Longtime User Jun 23, 2016 #2 I suppose your code is like this Code: Dim i as int i = 0 myVariable = map.GetKeyAt(i) deppending on what Type is myvaraible - if it is a double type - you will get an error...?! Upvote 0
I suppose your code is like this Code: Dim i as int i = 0 myVariable = map.GetKeyAt(i) deppending on what Type is myvaraible - if it is a double type - you will get an error...?!
imgsimonebiliato Well-Known Member Licensed User Longtime User Jun 23, 2016 #3 eurojam said: I suppose your code is like this Code: Dim i as int i = 0 myVariable = map.GetKeyAt(i) deppending on what Type is myvaraible - if it is a double type - you will get an error...?! Click to expand... My code it's like this: Code: Dim k As String Dim i as int i = 0 k = map.GetKeyAt(i) I need a string, not a double Upvote 0
eurojam said: I suppose your code is like this Code: Dim i as int i = 0 myVariable = map.GetKeyAt(i) deppending on what Type is myvaraible - if it is a double type - you will get an error...?! Click to expand... My code it's like this: Code: Dim k As String Dim i as int i = 0 k = map.GetKeyAt(i) I need a string, not a double
udg Expert Licensed User Longtime User Jun 23, 2016 #4 Your file name used for the key is evaluated as being a number, a double due to the "decimal" point, so the conversion from string to doubke fails for what is the file extension but it is read as the decimal part of your double. Upvote 0
Your file name used for the key is evaluated as being a number, a double due to the "decimal" point, so the conversion from string to doubke fails for what is the file extension but it is read as the decimal part of your double.
imgsimonebiliato Well-Known Member Licensed User Longtime User Jun 23, 2016 #5 udg said: Your file name used for the key is evaluated as being a number, a double due to the "decimal" point, so the conversion from string to doubke fails for what is the file extension but it is read as the decimal part of your double. Click to expand... I don't understand. How could be a double, if there is the word ".jpg"? Upvote 0
udg said: Your file name used for the key is evaluated as being a number, a double due to the "decimal" point, so the conversion from string to doubke fails for what is the file extension but it is read as the decimal part of your double. Click to expand... I don't understand. How could be a double, if there is the word ".jpg"?
udg Expert Licensed User Longtime User Jun 23, 2016 #6 I guess the problem arises because the filename part is an all-digits one so something looks at it like a number and having a full stop between filename and extension that makes it for a decimal number so the conversion routine from string to double which obviously fails. Try without the full stop and it will work..just for testing. Upvote 0
I guess the problem arises because the filename part is an all-digits one so something looks at it like a number and having a full stop between filename and extension that makes it for a decimal number so the conversion routine from string to double which obviously fails. Try without the full stop and it will work..just for testing.
imgsimonebiliato Well-Known Member Licensed User Longtime User Jun 23, 2016 #7 udg said: I guess the problem arises because the filename part is an all-digits one so something looks at it like a number and having a full stop between filename and extension that makes it for a decimal number so the conversion routine from string to double which obviously fails. Try without the full stop and it will work..just for testing. Click to expand... Without the full stop? What do you mean? Upvote 0
udg said: I guess the problem arises because the filename part is an all-digits one so something looks at it like a number and having a full stop between filename and extension that makes it for a decimal number so the conversion routine from string to double which obviously fails. Try without the full stop and it will work..just for testing. Click to expand... Without the full stop? What do you mean?
eurojam Well-Known Member Licensed User Longtime User Jun 23, 2016 #8 I have tried this snipplet without any error.... Code: Dim i As Int Dim map As Map map.Initialize map.Put("2016062309343853.jpg", "c:\desktop") i = 0 Dim k As String = map.GetKeyAt(i) Log(k) Upvote 0
I have tried this snipplet without any error.... Code: Dim i As Int Dim map As Map map.Initialize map.Put("2016062309343853.jpg", "c:\desktop") i = 0 Dim k As String = map.GetKeyAt(i) Log(k)
imgsimonebiliato Well-Known Member Licensed User Longtime User Jun 23, 2016 #9 eurojam said: I have tried this snipplet without any error.... Code: Dim i As Int Dim map As Map map.Initialize map.Put("2016062309343853.jpg", "c:\desktop") i = 0 Dim k As String = map.GetKeyAt(i) Log(k) Click to expand... Neither me. But in another part of code, yes Upvote 0
eurojam said: I have tried this snipplet without any error.... Code: Dim i As Int Dim map As Map map.Initialize map.Put("2016062309343853.jpg", "c:\desktop") i = 0 Dim k As String = map.GetKeyAt(i) Log(k) Click to expand... Neither me. But in another part of code, yes
Erel B4X founder Staff member Licensed User Longtime User Jun 23, 2016 #10 udg said: Your file name used for the key is evaluated as being a number, a double due to the "decimal" point, so the conversion from string to doubke fails for what is the file extension but it is read as the decimal part of your double. Click to expand... This is not the reason for this error. Please run your code in debug mode and post the line that raises the error. Note that it is a mistake to use Map.GetKeyAt, but it is not related to this error. Upvote 0
udg said: Your file name used for the key is evaluated as being a number, a double due to the "decimal" point, so the conversion from string to doubke fails for what is the file extension but it is read as the decimal part of your double. Click to expand... This is not the reason for this error. Please run your code in debug mode and post the line that raises the error. Note that it is a mistake to use Map.GetKeyAt, but it is not related to this error.
udg Expert Licensed User Longtime User Jun 23, 2016 #11 Reading post #9 it seems that the problematic programs sportse two code blocks supposed to be identical, where only one causes the error. If this is the case I'll try to figure out the difference between the two since @eurojams code works properly and the OP confirms it. Upvote 0
Reading post #9 it seems that the problematic programs sportse two code blocks supposed to be identical, where only one causes the error. If this is the case I'll try to figure out the difference between the two since @eurojams code works properly and the OP confirms it.