Android Question Building Array

ykucuk

Well-Known Member
Licensed User
Longtime User
how can i replace this line
B4X:
sv1.Data = Array As Float(15,16.5,16.70,17,15,15,15)
with add value one by one

.add(20)
.add(21.5)
 

Star-Dust

Expert
Licensed User
Longtime User
What is Sv1?
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Try (byteConverter library)
B4X:
Sv1.data=Merge(Sv1.data,array as float (20))
Sv1.data=Merge(Sv1.data,array as float (79,12.9))

B4X:
private Sub Merge(Array1() As Float, Array2() As Float) As Object
    Private BC As ByteConverter
    Dim FloatArray(Array1.Length + Array2.Length) As Float

    BC.ArrayCopy(Array1,0,FloatArray,0,Array1.Length)
    BC.ArrayCopy(Array2,0,FloatArray,Array1.Length,Array2.Length)
    Return FloatArray
End Sub
 
Last edited:
Upvote 0

ykucuk

Well-Known Member
Licensed User
Longtime User
Try (BinaryConvert library)

B4X:
BufferFloat=Merge(BufferByte,array as float (20))
BufferFloat=Merge(BufferByte,array as float (79,12.9))

B4X:
private Sub Merge(Array1() As Float, Array2() As Float) As Object
    Private BC As ByteConverter
    Dim FloatArray(Array1.Length + Array2.Length) As Float

    BC.ArrayCopy(Array1,0,FloatArray,0,Array1.Length)
    BC.ArrayCopy(Array2,0,FloatArray,Array1.Length,Array2.Length)
    Return FloatArray
End Sub

thank you for help. i didnt find BinaryConvert Lib. could u give me link for this ?

Do you mean "ByteConverter"?

What is type of BufferByte ?

What is type of BufferFloat?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Sorry ByteConverter :oops:
But can use cicle for also
 
Last edited:
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
thank you for help. i didnt find BinaryConvert Lib. could u give me link for this ?

Do you mean "ByteConverter"?

What is type of BufferByte ?

What is type of BufferFloat?
I answered your questions by correcting the example to fit your case (post#3).
I thought you could guess the correspondence.

Also I added another method:
B4X:
Sv1.data=Merge(Sv1.data,array as float (20))
Sv1.data=Merge(Sv1.data,array as float (79,12.9))

B4X:
private Sub Merge(Array1() As Float, Array2() As Float) As Object
    Dim FloatArray(Array1.Length + Array2.Length) As Float

    For I=0 To Array1.length-1
        FloatArray(I)=Array1(I)
    Next

    For I=0 To Array2.length-1
        FloatArray(Array1.Length+I)=Array1(I)
    Next

    Return FloatArray
End Sub
 
Last edited:
Upvote 0
Top