View Full Version : STAT_CLONEARRAY and UDT
DirectuX
23-10-2019, 17:04
10083
STAT_CLONEARRAY and UDT , aren't they compatible ?
ErosOlmi
24-10-2019, 20:15
No, I'm sorry
It works only on numeric arrays
In general STAT module was intended to work with numeric arrays
Petr Schreiber
24-10-2019, 22:34
Hi Sebastian,
I think you can perform duplicate for example this way:
uses "Console"
type Vector3D
x as float32
y as float32
end type
dim arr(3) as Vector3D
dim arr_copy(3) as Vector3D
int32 i
for i = 1 to ubound(arr)
arr(i).x = i
arr(i).y = i
next
' This is like "copy bytes from start of the array, of total length calculated like number-of-elements * size-of-element and store them to string"
' VarPtr is "variable pointer"
string binary = peek$(varptr(arr(1)), CountOf(arr(1))*SizeOf(arr(1)))
' This is like - "paste the binary string at place starting at beginning of arr_copy"
poke$(varptr(arr_copy(1)), binary)
printl "Source array:"
for i = 1 to ubound(arr)
printl arr(i).x, arr(i).y
next
printl
printl "Copied array:"
for i = 1 to ubound(arr)
printl arr_copy(i).x, arr_copy(i).y
next
waitkey
Petr
DirectuX
25-10-2019, 20:30
Thanks both,
Eros I think the core ARRAY series (https://www.thinbasic.com/public/products/thinBasic/help/html/array_assign.htm) functions may benefit of such ARRAY COPY and ARRAY CLONE functions.
Petr Schreiber
25-10-2019, 20:49
That would be nice!
Petr