Hi,
I have used the below function by Erel for some time in B4J from another case:
B4X:
Sub StringToUnsignedInt (Str As String) As Long
Dim converter As ByteConverter
Dim a(8) As Byte
Dim i() As Byte = converter.HexToBytes(Str)
Bit.ArrayCopy(i, 0, a, 4, 4)
Dim ll() As Long = converter.LongsFromBytes(a)
Return ll(0)
End Sub
B4r bit object does not have the "ArrayCopy" method so it won't build. Any workaround?
thanks!
still have some issues. for some numbers the method throws NumberFormatException.
For example
Dim v_ulong As ULong = Bit.ParseInt("E0E09E61", 16)
any idea?
java.lang.NumberFormatException: For input string: "E0E09E61"
at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.base/java.lang.Integer.parseInt(Integer.java:652)
at anywheresoftware.b4a.keywords.Bit.ParseInt(Bit.java:86)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:632)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
...................
still have some issues. for some numbers the method throws NumberFormatException.
For example
Dim v_ulong As ULong = Bit.ParseInt("E0E09E61", 16)
any idea?
java.lang.NumberFormatException: For input string: "E0E09E61"
at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.base/java.lang.Integer.parseInt(Integer.java:652)
at anywheresoftware.b4a.keywords.Bit.ParseInt(Bit.java:86)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:632)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
...................