Function Reference


_ArrayMaxIndex

Returns the index where the highest value occurs in a 1D or 2D array

#include <Array.au3>
_ArrayMaxIndex ( Const ByRef $aArray [, $iCompNumeric = 0 [, $iStart = -1 [, $iEnd = -1 [, $iSubItem = 0]]]] )

Parameters

$aArray Array to search
$iCompNumeric [optional] Comparison method:
    0 - compare alphanumerically
    1 - compare numerically
$iStart [optional] Index of array to start search
$iEnd [optional] Index of array to end search
$iSubItem [optional] Column of array to search

Return Value

Success: the index of the maximum value in the array.
Failure: -1 and sets the @error flag to non-zero.
@error: 1 - $aArray is not an array or is empty
2 - $aArray is not a 1D or 2D array
3 - $iStart or $iEnd outside array bounds
4 - $iStart is greater than $iEnd
5 - $aArray is empty
6 - $iSubItem outside array bounds

Related

_ArrayMax, _ArrayMin, _ArrayMinIndex

Example

#include <Array.au3>
#include <MsgBoxConstants.au3>

Local $aArray = StringSplit("4,2,06,8,12,5", ",")

MsgBox($MB_SYSTEMMODAL, 'Max Index String value', _ArrayMaxIndex($aArray, 0, 1))
MsgBox($MB_SYSTEMMODAL, 'Max Index Numeric value', _ArrayMaxIndex($aArray, 1, 1))

Local $aArray[4][4]
For $i = 0 To 3
    For $j = 0 To 3
        $aArray[$i][$j] = Random(0, 99, 1)
    Next
Next
_ArrayDisplay($aArray, "2D Array")
MsgBox($MB_SYSTEMMODAL, 'Max Index Numeric value in column 2', _ArrayMaxIndex($aArray, 1, 0, 0, 2))