Android Question Help, i cant get my head around this

joolzg

Member
Licensed User
Longtime User
I have some code which pulls in data from a web server and this is in binary so i need to parse it manually.

So for stage 1 I have made up an array of ints to simulate the data

Dim testCmd = Array As Int ( 0x41, 0x01, 0x00, 0x0a, 0x42, 0x02, 0x22, 0x22, 0x0a )

Here is the walk code
Sub ProcessInputFromServer2( inp() As Int , length As Int) As Int
Dim offset As Int

offset = 0
Do While length > 0
offset = offset + 3 + inp( offset + 1)
length = length - ( 3 + inp( offset + 1) )
Loop

Return 0
End Sub

Now im trying to pass this array of ints to the process routine
ProcessInputFromServer2( testCmd, testCmd.length)

how do i pass the array to the routine?

And the final problem is when I get the real data I get BYTEs, like this
Dim newdata( 2048) As Byte

' Find and walk the binary package returned here
input = HttpUtils.GetInputStream( channelUrl)
length = input.ReadBytes( newdata, 0, input.BytesAvailable)
input.Close
'need newdata as array of ints, ByteConvertor?
'ProcessInputFromServer( newdata, length)

Any expert out there help

joolz
 

joolzg

Member
Licensed User
Longtime User
ProcessInputFromServer2( testCmd , testCmd.Length)

Thanks for that but I tried that and here is the error i get

B4A version: 6.00
Parsing code. (0.01s)
Compiling code. Error
Error compiling program.
Error description: Cannot cast type: {Type=String,Rank=0, RemoteObject=True} to: {Type=Int,Rank=1, RemoteObject=True}
Occurred on line: 211
ProcessInputFromServer2( testCmd, testCmd.length)
Word: testcmd

This is the line at 211
ProcessInputFromServer2( testCmd, testCmd.length)

Seems to be the testCmd, as in the warnings window i get a warning about testCmd being converted to a string, warning #5
 
Upvote 0
Top