Inserts a specified column into a 1D or 2D array
#include <Array.au3>
_ArrayColInsert ( ByRef $aArray, $iColumn )
$aArray | Array to modify |
$iColumn | Column to insert - if array is 1D it is automatically converted to 2D |
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 1D or 2D array 3 - $iColumn is less than 0 or greater than upper array bound plus 1 |
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] = [0, 1, 2, 3]
_ArrayDisplay($aArray, "Original")
_ArrayColInsert($aArray, 0)
; Now a 2D array
_ArrayDisplay($aArray, "Col 0 inserted")
_ArrayColInsert($aArray, 1)
_ArrayDisplay($aArray, "Col 1 inserted")
_ArrayColInsert($aArray, 3)
_ArrayDisplay($aArray, "Col 3 inserted")