Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Clearing an array
#6
(2021-04-15, 09:27 PM)worcestersource Wrote: Just the clarify the syntax for copying an array, if mine has dimensions of 27,7, I'd type:

Code:
array1(27,7) = array2(27,7)

Because doing this doesn't appear to copy the data.

Thanks,


Steve

Ah. I figured it out. In the example above, it is literally as Boriel said.

Code:
array1 = array2


What's great with the quick code/compile cycle is that you can use trial and error to figure things out. Smile

Steve

This works. But array2 is always taking your memory. Consider using this within a function so once the function ends, array2 is freed from memory.
Code:
SUB initArray()
    DIM array2(...)
    array1 = array2
END SUB ' Here array2 is freed

Another solution is to use memset (if the array is NOT an array of strings), but these is a bit more complex.

Anyway, this will be available in the near future once I manage to implement DIM for dynamic arrays (as in SinclairBASIC), and REDIM.
Reply


Messages In This Thread
Clearing an array - by patters - 2021-01-19, 11:47 PM
RE: Clearing an array - by Ljg701 - 2021-01-20, 12:30 PM
RE: Clearing an array - by boriel - 2021-01-20, 03:15 PM
RE: Clearing an array - by patters - 2021-01-26, 02:04 AM
RE: Clearing an array - by worcestersource - 2021-04-15, 09:27 PM
RE: Clearing an array - by boriel - 2021-04-16, 11:43 AM
RE: Clearing an array - by worcestersource - 2021-04-16, 09:00 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)