Trims a certain number of characters from all elements in a 1D or 2D array
#include <Array.au3>
_ArrayTrim ( ByRef $aArray, $iTrimNum [, $iDirection = 0 [, $iStart = 0 [, $iEnd = 0 [, $iSubItem = 0]]]] )
$aArray | Array to modify |
$iTrimNum | Number of characters to remove |
$iDirection | [optional] Direction to trim: 0 - trim left 1 - trim right |
$iStart | [optional] Index of array to start trim |
$iEnd | [optional] Index of array to stop trim |
$iSubItem | [optional] Column to trim |
Success: | 1. |
Failure: | 0 and sets the @error flag to non-zero. |
@error: | 1 - $aArray is not an array 2 - $aArray is not an 1D or 2D array 3 - $iStart or $iEnd outside array bounds 4 - $iStart is greater than $iEnd 5 - $iSubItem outside array bounds |
#include <Array.au3>
Local $aArray[5] = ["ab", "bc", "cd", "de", "ef"]
_ArrayDisplay($aArray, "1D array")
_ArrayTrim($aArray, 1, 1, 1, 3)
_ArrayDisplay($aArray, "Trimmed right 1 char from items 1-3")
Local $aArray[4][4], $iChr
For $i = 0 To 3
For $j = 0 To 3
$iChr = Random(97, 121, 1)
$aArray[$i][$j] = Chr($iChr) & Chr($iChr + 1)
Next
Next
_ArrayDisplay($aArray, "2D array")
_ArrayTrim($aArray, 1, 0, 1, 2, 3)
_ArrayDisplay($aArray, "Trimmed left 1 char from col 2-3 in row 1-2")