Resizing and Deleting Arrays

BlitzMax Forums/BlitzMax Beginners Area/Resizing and Deleting Arrays

po(Posted 2009) [#1]
I've completely forgotten how to resize an already existing array, as well as delete/release/free existing arrays. Any help is appreciated, thanks.


plash(Posted 2009) [#2]
Deleting an array, just like any other object, is as simple as setting the variable to Null.

See MaxIDE Help > Language > Slices for resizing.


xlsior(Posted 2009) [#3]
From the help: (help -> language -> advanced topics -> slicing)

Local a[200]	'initialize a[] to 200 elements
a=a[50..150]	'extract middle 100 elements of a[]
a=a[..50]     	'extract first 50 elements of a[]
a=a[25..]	'extract elements starting from index 25 of a[]
a=a[..]		'copy all elements of a[]
a=a[..200]	'resize a[] to 200 elements



Arowx(Posted 2009) [#4]
Which is fine when you are dealing with a single array dimension but it get's confusing when you need multiple dimensions, does slicing work for multiple dimensions e.g.

Local a[200,200]
a=a[50..150,50..150] 'middle 100,100 element of a[]
a=a[..50,..50]     	'extract first 50 elements of a[]
a=a[25..,25..]	'extract elements starting from index 25 of a[]
a=a[..,..]		'copy all elements of a[]
a=a[..200,..200]	'resize a[] to 200 elements

?


plash(Posted 2009) [#5]
...does slicing work for multiple dimensions[?]
No.


xlsior(Posted 2009) [#6]
does slicing work for multiple dimensions e.g.


No -- I just tried it, and got the following error: "Slices can only be used with strings or one dimensional arrays"