D Declan Well-Known Member Licensed User Longtime User Aug 31, 2017 #1 Hi, I am trying to parse the data as follows: Code: Copy ' Input Data (cFrame) HEX = 53193315451c0a2d2a410000 Dim GEOLat As String Dim GEOLon As String GEOLat = cFrame.SubString2(2,8) GEOLon = cFrame.SubString2(10,16) GEOLat = ParseHexToFloat(GEOLat) GEOLon = ParseHexToFloat(GEOLon) Code: Copy Sub ParseHexToFloat(hex As String) As Float Dim BC As ByteConverter Return BC.FloatsFromBytes(BC.HexToBytes(hex))(0) '<<---Error End Sub I Receive the following Error: Code: Copy Error occurred on line: 103 java.lang.ArrayIndexOutOfBoundsException at java.lang.reflect.Array.get(Native Method) at anywheresoftware.b4a.shell.ArraysUtils.getElement(ArraysUtils.java:76) at anywheresoftware.b4a.shell.Shell.getArrayElement(Shell.java:471) at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:263) at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90) at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:93) at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:61) at b4j.example.sigfox._hnsconvertreturn(sigfox.java:223) at b4j.example.sigfox._handle(sigfox.java:206) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:614) at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:231) at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90) at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:93) at anywheresoftware.b4a.BA.raiseEvent(BA.java:77) at anywheresoftware.b4j.object.JServlet$Handle.run(JServlet.java:130) at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:30) at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:26) at anywheresoftware.b4a.ShellBA.startMessageLoop(ShellBA.java:114) at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:146) at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:303) at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90) at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:93) at anywheresoftware.b4a.BA.raiseEvent(BA.java:77) at b4j.example.main.main(main.java:29)
Hi, I am trying to parse the data as follows: Code: Copy ' Input Data (cFrame) HEX = 53193315451c0a2d2a410000 Dim GEOLat As String Dim GEOLon As String GEOLat = cFrame.SubString2(2,8) GEOLon = cFrame.SubString2(10,16) GEOLat = ParseHexToFloat(GEOLat) GEOLon = ParseHexToFloat(GEOLon) Code: Copy Sub ParseHexToFloat(hex As String) As Float Dim BC As ByteConverter Return BC.FloatsFromBytes(BC.HexToBytes(hex))(0) '<<---Error End Sub I Receive the following Error: Code: Copy Error occurred on line: 103 java.lang.ArrayIndexOutOfBoundsException at java.lang.reflect.Array.get(Native Method) at anywheresoftware.b4a.shell.ArraysUtils.getElement(ArraysUtils.java:76) at anywheresoftware.b4a.shell.Shell.getArrayElement(Shell.java:471) at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:263) at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90) at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:93) at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:61) at b4j.example.sigfox._hnsconvertreturn(sigfox.java:223) at b4j.example.sigfox._handle(sigfox.java:206) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:614) at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:231) at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90) at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:93) at anywheresoftware.b4a.BA.raiseEvent(BA.java:77) at anywheresoftware.b4j.object.JServlet$Handle.run(JServlet.java:130) at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:30) at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:26) at anywheresoftware.b4a.ShellBA.startMessageLoop(ShellBA.java:114) at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:146) at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:303) at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90) at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:93) at anywheresoftware.b4a.BA.raiseEvent(BA.java:77) at b4j.example.main.main(main.java:29)
Daestrum Expert Licensed User Longtime User Aug 31, 2017 #2 Think you need to help the compiler determine what the string represents Try Code: Copy GEOLat = "0x" & cFrame.SubString2(2,8) GEOLon = "0x" & cFrame.SubString2(10,16) Upvote 0
Think you need to help the compiler determine what the string represents Try Code: Copy GEOLat = "0x" & cFrame.SubString2(2,8) GEOLon = "0x" & cFrame.SubString2(10,16)
D Declan Well-Known Member Licensed User Longtime User Aug 31, 2017 #3 Thanks, but not working: GEOLat = "0x" & cFrame.SubString2(2,8) Click to expand... Gives: 0x193315 GEOLon = "0x" & cFrame.SubString2(10,16) Click to expand... Gives: 0x1c0a2d Upvote 0
Thanks, but not working: GEOLat = "0x" & cFrame.SubString2(2,8) Click to expand... Gives: 0x193315 GEOLon = "0x" & cFrame.SubString2(10,16) Click to expand... Gives: 0x1c0a2d
stevel05 Expert Licensed User Longtime User Aug 31, 2017 #4 A float should be represented as 4 bytes, you are only passing 3. Upvote 0