it's a very limited example but it really concatenates 2 arrays with the help of the standard operators, like & on strings, and a simple user defined Union. This is an alternative to the writing of a for loop reading old arrays index by index and writting them to the new array. This is not what is done here at all.
Code: Select all
'suppose we work with those kind of length=4 byte arrays
'let's construct 2 arrays
dim as ubyte bytearray1(3)
dim as ubyte bytearray2(3)
for i as integer = lbound(bytearray1) to ubound(bytearray1)
bytearray1(i) = &hFE - i*16
next i
for i as integer = lbound(bytearray1) to ubound(bytearray1)
bytearray2(i) = &hAE - i*16
next i
'change the arrays content into plain integers
dim as uinteger<4*8> ptr uiptr1
uiptr1 = Cast(uinteger<4*8> ptr, @bytearray1(0)) '' *uiptr eats the byte array on its 4bytes integer length
dim as uinteger<4*8> ptr uiptr2
uiptr2 = Cast(uinteger<4*8> ptr, @bytearray2(0))
'append the 2 arrays in a 3rd one via a Union and & operator
union U
as uinteger<8*8> ui
as string*8 s8
end union
dim as U uu1, uu2, uu3
uu1.ui = *uiptr1
uu2.ui = *uiptr2
uu3.s8 = uu1.s8 & uu2.s8
dim as ubyte finalsum(7)
*( cptr(uinteger<8*8> ptr, @finalsum(0)) ) = uu3.ui
''result:
for i as integer = lbound(finalsum) to ubound(finalsum)
? hex(finalsum(i));
next i : ?
'(eof)