P PaulR Active Member Licensed User Longtime User Mar 17, 2012 #1 Hi What is the syntax for appending to arrays of Bytes? I can use the ArrayCopy from the ByteConverter library to go back and forward between arrays, and access individual byte positions but is there an easier way of appending? Cheers!
Hi What is the syntax for appending to arrays of Bytes? I can use the ArrayCopy from the ByteConverter library to go back and forward between arrays, and access individual byte positions but is there an easier way of appending? Cheers!
Erel B4X founder Staff member Licensed User Longtime User Mar 17, 2012 #2 Unlike Lists arrays have a predefined size. You cannot increase the size of an array without creating a completely new array. You can however create a dynamic memory stream using OutputStream.InitializeToBytesArray. Upvote 0
Unlike Lists arrays have a predefined size. You cannot increase the size of an array without creating a completely new array. You can however create a dynamic memory stream using OutputStream.InitializeToBytesArray.
P PaulR Active Member Licensed User Longtime User Mar 17, 2012 #3 Okay, so they are the same as normal C arrays... thanks. OutputStream looks perfect for this stuff (which will be why you implemented it) . Upvote 0
Okay, so they are the same as normal C arrays... thanks. OutputStream looks perfect for this stuff (which will be why you implemented it) .
P PaulR Active Member Licensed User Longtime User Mar 19, 2012 #4 I think the autocomplete tooltip for OutputStream.WriteBytes is wrong when it says Length as Int has to be the length - 1. My code works when the StartOffset = 0 and Length = Length. eg a 32 bit Int has a length of 4 bytes and the values StartOffset = 0 and Length = 4 is correct for that. Upvote 0
I think the autocomplete tooltip for OutputStream.WriteBytes is wrong when it says Length as Int has to be the length - 1. My code works when the StartOffset = 0 and Length = Length. eg a 32 bit Int has a length of 4 bytes and the values StartOffset = 0 and Length = 4 is correct for that.
Erel B4X founder Staff member Licensed User Longtime User Mar 19, 2012 #5 If you have a bytes array of 4 bytes then the indices of the array are: 0, 1, 2 and 3. The sentence means that the first byte that will be written is Buffer(0) and the last is Buffer(4 - 1), which is correct. Upvote 0
If you have a bytes array of 4 bytes then the indices of the array are: 0, 1, 2 and 3. The sentence means that the first byte that will be written is Buffer(0) and the last is Buffer(4 - 1), which is correct.