Performs in-place removal of an element from a single dimension array, or the in-place removal of a row or column from a two dimension array.
ArrayRemove ( array, sub, [ dim ] )
(a) array: the array in which to remove an element, row, or column.
(i) sub: subscript of the element to remove in single dimension array or the subscript of the row or column to remove in a two dimension array.
(i) dim: [optional] must be 1 or omitted for one dimension arrays. Must be either 1 to delete an array row or 2 to delete an array column from a two dimension array.
(i) returns 1.
Note: This function cannot be used to remove a single element from a two dimensional array.
Multidimensional arrays in WinBatch use 'Row Major' format. For Example: arrMyArray[ row_index , column_index ]
;------------------------------------------------------ ; SINGLE DIMENSION - Remove a single element ;------------------------------------------------------ ; Allocate a single dimension array with 6 elements. array = ArrDimension( 6 ) ArrInitialize( array, 0 ) Pause( 'Array Element Count', ArrInfo( array, 1 ) ) ; Remove the first element ArrayRemove( array, 0) Pause( 'Array Element Count', ArrInfo( array, 1 ) ) ; Remove the 3rd element ArrayRemove( array, 2) Pause( 'Array Element Count', ArrInfo( array, 1 ) ) ; Remove the last element ArrayRemove( array, ArrInfo( array, 1 ) - 1 ) Pause( 'Array Element Count', ArrInfo( array, 1 ) )
;------------------------------------------------------ ; TWO DIMENSION - Remove a row. ;------------------------------------------------------ ; Allocate a two dimensional array with 6 elements in each dimension. array = ArrDimension( 6, 6 ) ArrInitialize( array, 0 ) Pause( 'Array Element Count', 'Rows: ': ArrInfo( array, 1 ): @CRLF : 'Columns: ': ArrInfo( array, 2 )) ; Remove the first row ArrayRemove( array, 0, 1) Pause( 'Array Element Count', 'Rows: ': ArrInfo( array, 1 ): @CRLF : 'Columns: ': ArrInfo( array, 2 )) ; Remove the 3rd row ArrayRemove( array, 2, 1) Pause( 'Array Element Count', 'Rows: ': ArrInfo( array, 1 ): @CRLF : 'Columns: ': ArrInfo( array, 2 )) ; Remove the last row ArrayRemove( array, ArrInfo( array, 1 ) - 1 , 1) Pause( 'Array Element Count', 'Rows: ': ArrInfo( array, 1 ): @CRLF : 'Columns: ': ArrInfo( array, 2 ))
;------------------------------------------------------ ; TWO DIMENSION - Remove a column. ;------------------------------------------------------ ; Allocate a two dimensional array with 6 elements in each dimension. array = ArrDimension( 6, 6 ) ArrInitialize( array, 0 ) Pause( 'Array Element Count', 'Rows: ': ArrInfo( array, 1 ): @CRLF : 'Columns: ': ArrInfo( array, 2 )) ; Remove the first column ArrayRemove( array, 0, 2) Pause( 'Array Element Count', 'Rows: ': ArrInfo( array, 1 ): @CRLF : 'Columns: ': ArrInfo( array, 2 )) ; Remove the 3rd column ArrayRemove( array, 2, 2) Pause( 'Array Element Count', 'Rows: ': ArrInfo( array, 1 ): @CRLF : 'Columns: ': ArrInfo( array, 2 )) ; Remove the last column ArrayRemove( array, ArrInfo( array, 2 ) - 1 , 2) Pause( 'Array Element Count', 'Rows: ': ArrInfo( array, 1 ): @CRLF : 'Columns: ': ArrInfo( array, 2 ))
Arrays, ArrayFileGet, ArrayFileGetCsv, ArrayFilePut, ArrayFilePutCsv, ArrayFromStr, ArrayInsert, ArrayItemize, Arrayize, ArrayLocate, ArrayRedim, ArrayReverse, ArraySort, ArraySwapElements, ArrayToStr, ArrDimension, ArrInfo, ArrInitalize, Drop