Sign in to follow this  
Followers 0
tnok85

_ArrayMinIndex/MaxIndex

2 posts in this topic

#include <Array.au3>

Local $avArray[11] = [1, 5, 1, 7, 66, 12, 1, 66, 11, 5, 1]

MsgBox(0,'Min Index Numeric value', _ArrayMinIndex($avArray, 1))
MsgBox(0,'Max Index Numeric value', _ArrayMaxIndex($avArray, 1))

It seems to only return the first min and first max. (Min shows 0, max shows 4) I'd like to have it show you *all* minimums and *all* maximums if there is more than one min or max.

Share this post


Link to post
Share on other sites



Then wrap the functions in an enumeration:

#include <Array.au3>

Local $avArray[11] = [1, 5, 1, 7, 66, 12, 1, 66, 11, 5, 1]

Local $i_ArrayMin = $avArray[_ArrayMinIndex($avArray, 1)]
For $i = 0 To UBound($avArray) - 1
    If $avArray[$i] = $i_ArrayMin Then ConsoleWrite("Min " & $i_ArrayMin & " found at " & $i & @CRLF)
Next

Local $i_ArrayMax = $avArray[_ArrayMaxIndex($avArray, 1)]
For $i = 0 To UBound($avArray) - 1
    If $avArray[$i] = $i_ArrayMax Then ConsoleWrite("Max " & $i_ArrayMax & " found at " & $i & @CRLF)
Next

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0