1. I want to get the 42BBD001 hex and turn it structure like this 01D0BB42. Is it possible? Is it using string manipulation (char at()) ) and store it to an array and construct it again by calling one by one or is there any other method?
2. Second of all, how to convert the hex to decimal? Is it use the "hextoByte" function and pass it to the other function "IntfromByte" that found in the byteconv library?I want to turn this hex "01D0BB42" to ssomething like this in decimal "30456642"
didn't test it but this might work for question 1 & 2
B4X:
dim t as string ="6B800800 42BBD001 BD769B3C DA010100 BAFFFFFF 00000000 01009A53 34DB"
dim data() as string
data=regex.split(" ",t) 'split elements
data=regex.split("",data(1)) 'take the 42BBD001 element
t=data(6)&data(7)&data(4)&data(5)&data(2)&data(3)&data(0)&data(1) 'reverse it
log ( Bit.ParseInt(t, 32) ) ' show as non hex value
didn't test it but this might work for question 1 & 2
B4X:
dim t as string ="6B800800 42BBD001 BD769B3C DA010100 BAFFFFFF 00000000 01009A53 34DB"
dim data() as string
data=regex.split(" ",t) 'split elements
data=regex.split("",data(1)) 'take the 42BBD001 element
t=data(6)&data(7)&data(4)&data(5)&data(2)&data(3)&data(0)&data(1) 'reverse it
log ( Bit.ParseInt(t, 32) ) ' show as non hex value
Good day to all of you. Thanks for help me out of my problem.
I have change a little bit of your coding and now it work.
B4X:
Dim t As String ="6B800800 42BBD001 BD769B3C DA010100 BAFFFFFF 00000000 01009A53 34DB"
Dim data() As String
data=Regex.split(" ",t) 'split elements
data=Regex.split("",data(1)) 'take the 42BBD001 element
t=data(7)&data(8)&data(5)&data(6)&data(3)&data(4)&data(1)&data(2) 'reverse it
Log ( Bit.ParseInt(t, 16) ) ' show as non hex value
End Sub
For some reason data(0) hold value of 0. I have change it like the above code.
I'm thinking it might be a bug in the Java implementation of regex. The regular expression "" might be making a match at the start of the string and not just between each character.
Calling the sub below instead of regex.split() will work as expected.
B4X:
Sub StringSplit(s As String) As String()
Dim a(s.Length) As String
Dim i As Int
For i = 0 To s.Length - 1
a(i) = s.CharAt(i)
Next
Return a
End Sub