ArrayRedim

Changes array dimensions in-place.

Syntax:

ArrayRedim ( array, dim1 [, dim2 [, dim3 [, dim4 [, dim5 ] ] ] ] )

Parameters:

(a) array: array to re-dimension.

(i) "dim1"- "dim5": specifies the new "array" of up to 5 dimensions or -1 to keep existing dimensions. The default for "dim2" through "dim5" is 0 which deletes the existing dimension. Once an array dimension is set to 0, all subsequent array dimensions must be set to 0 or omitted.  -1 can also be used for subsequent dimensions if current corresponding dimension is already 0.

Returns:

(i) returns 1.

 

ArrayRedim changes array dimensions in-place. When used to increase array dimensions, preserves all array content. When any array dimension is reduced in size, the array content referenced by the eliminated indices is lost even if the overall array size remains unchanged or increases, due to increases in the size of other dimensions.  

ArrayRedim takes a variable number of parameters, with the first two parameters being required, and last four optional.

Note: if you shrink the array, data in the removed dimensions will be lost. This function does not support array 'folding'.

For example:

1-dimension array: ArrayRedim(array1, 10)
2-dimension array: ArrayRedim(array2,10, 10)
3-dimension array: ArrayRedim(array3, 10, 10, 10)
4-dimension array: ArrayRedim(array4, 10, 10, 10, 10)
5-dimension array: ArrayRedim(array5, 10, 10, 10, 10, 10)
Example:
 
; Allocate an array with 6 elements. array = ArrDimension( 6 ) ArrInitialize( array, 0 ) Pause( 'Array Element Count', ArrInfo( array, 1 ) )
; Resize the array ArrayRedim( array, 10 ) Pause( 'Array Element Count', ArrInfo( array, 1 ) )
 
See Also:

Arrays, ArrayFileGet, ArrayFileGetCsv, ArrayFilePut, ArrayFilePutCsv, ArrayFromStr, ArrayInsert,  ArrayItemize, Arrayize, ArrayLocate, ArrayRemove, ArrayReverse, ArraySort, ArraySwapElements, ArrayToStr, ArrDimension, ArrInfo, ArrInitalize, Drop