Function Reference


Deletes a specified column from a 2D array

#include <Array.au3>
_ArrayColDelete ( ByRef $aArray, $iColumn [, $bConvert = False] )


$aArray Array to modify
$iColumn Column to delete
$bConvert [optional] If True then if only one column remains the array is converted to 1D

Return Value

Success: the number of columns remaining.
Failure: -1 and sets the @error flag to non-zero.
@error: 1 - $aArray is not an array
2 - $aArray is not a 2D array
3 - $iColumn is outside array bounds


The function does NOT update any count element within the array, but the return value of the function (if successful) gives the final number of columns in the array.




#include <Array.au3>

Local $aArray[4][3]
For $i = 0 To 3
    For $j = 0 To 2
        $aArray[$i][$j] = $i & $j
_ArrayDisplay($aArray, "Original")

_ArrayColDelete($aArray, 2)
_ArrayDisplay($aArray, "Col 2 Deleted")

; Copy 2 col array
Local $aArray_2Col = $aArray

; Default 1 column left as 2D array
_ArrayColDelete($aArray, 0)
_ArrayDisplay($aArray, "Col 0 del - 2D array")

; Convert 1 column array to 1D
_ArrayColDelete($aArray_2Col, 0, True)
_ArrayDisplay($aArray_2Col, "Col 0 del - 1D array")