Can I resize an arry within a function?

BlitzMax Forums/BlitzMax Beginners Area/Can I resize an arry within a function?

[edit] resize an ARRAY (of course)
And if I can; HOW?
I don't mind if the content is destroyed or not.
Or do I have to use banks for this purpose?

Is there a way to figure this kind of stuff out (an easy way) without bothering my fellow Blitzers? Some GOOD documentation somewhere?

t.i.a. for all your reactions. :)

read about array Slices .. theres a section in the languages ref page, heres the jist of it...
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



I guess if you want to resize within a functon, just pass the array to the function...

Help / Language / Slices in your documentation.
Wiki has some good stuff on arrays as well...
Wiki slices

thx, but i'm afraid slices won't do.
I don't want to create a huge array (just in case)when the "user" just needs a small one.
I was thinking more in the line of REDIM, or something.
(i'm getting the feeling i can start rewriting things, using banks) or are there other solutions?

slices *will* do .. what're you affraid of? :P

local smurf:int[10] ' <- now 10 smurfs
local gargamel:int=1337
smurf=smurf[..gargamel] ' <- now 1337 smurfs
smurf=smurf[..1] ' <- 1 smurf left :(


I'm afraid I meant resizing a multi-dimensional array.
I should have been more clear on that point.
Thanks anywho...

you can't unfortunately use slices on a multi-dimensional array, you can however use them on an Array of Arrays

If you don't need to keep the content, you can also do that:
Local a:Int[,,] ' array variable for a three-dimensional array
a = New Int[2,2,2] ' create small array
a = New Int[99,99,99] ' replace with big array
a = New Int[2,2,2] ' and small again
-- Byteemoz

Is there a way to figure this kind of stuff out (an easy way) without bothering my fellow Blitzers?
Try it?

Aah, to try and fail miserably! Story of my life!

[edit] (as to not to bump) njagnjag...
@Byteemoz:
That realy works like a charm!
	
Global array:Int[,,]  

resize(1,2,3)
resize(4,5,6)

Function resize(A:int,B:int,C:int)
   array = New Int[A,B,C] 	
End Function