Type casting: byte rank0 to byte rank1 error

PhilN

Member
Licensed User
Longtime User
Hi all,

I get this error: Cannot cast type: {Type=Byte,Rank=0} to: {Type=Byte,Rank=1}

B4X:
   Dim ScratchSTR As String
   Dim ScratchByte As Byte
   Dim ScratchInt As Int
   Dim BConv As ByteConverter

         ScratchByte = BConv.StringToBytes(ScratchSTR, "UTF8")
         ScratchInt = BConv.IntsFromBytes(ScratchByte)
What the difference between a byte rank0 and a byte rank1?
Is there anyone who can help to resolve this? Please... :sign0163: Any help is much appreciated...
 

mc73

Well-Known Member
Licensed User
Longtime User
Rank1 is an array. StringToBytes gets your string and returns an array of bytes, you can declare it as
B4X:
dim ScratchByte() as byte
. IntsFromBytes needs an array of bytes as input and returns again an array of ints. Thus you should declare
B4X:
Dim ScratchInt() as int
.
Here's the documentation for byteConverter.
 
Upvote 0
Top