(01-20-2021, 11:30 AM)Ljg701 Wrote: (01-19-2021, 10:47 PM)patters Wrote: What is the recommended way to reset an array's contents? Do we have to run a FOR loop from 0 TO UBOUND and clear it element by element, or is there a neater way?
I see that the following doesn't work:
You could get the address of the start of the array and then use the MemSet method in the memcopy library to clear it quickly?
That's it.
A proposal (I think even commented in this forum):
or
Code:
CLEAR array, <new value>
but it's not implemented.
Instead you should perhaps use memset:
Code:
#include <memcopy.bas>
DIM myArray(10, 20) as UByte => 11 rows x 21 cols if using array_base 0
..
memset(@myArray(0, 0), 0, 11 * 21)
When dynamics array are implemented you could also ReDIM them... meanwhile...
Finally, remember you can assign (copy) entire arrays (myArray1 = myArray2) provided they are of the same shape and type.