Jump to content

Find max index number in array


Recommended Posts

Hi,

i got this array: $Links1 or $Links2 or $Links3 and i want to find the max index number.

Like this:

$Links1[0] = 'hi'

$Links1[1] = 'hadf'

$Links1[2] = 'adsfdsfhi'

$Links1[3] = 'dfljaleuhi'

So i want to get the number 3...

I checked the helpfile for _ArrayMaxIndex and _ArrayMax but they doesn't give me the result i want, i'm probably coding it wrong :lmao:...

Like this example:

#include <Array.au3>

Dim $Links1[4]
$Links1[0] = 'hi'
$Links1[1] = 'hadf'
$Links1[2] = 'adsfdsfhi'
$Links1[3] = 'dfljaleuhi'

MsgBox(0,'Max Index String value',_ArrayMaxIndex( $Links1, 0, 0))
MsgBox(0,'Max Index String value',_ArrayMaxIndex( $Links1, 0, 1))
MsgBox(0,'Max Index Numeric value',_ArrayMaxIndex( $Links1, 1, 0))
MsgBox(0,'Max Index Numeric value',_ArrayMaxIndex( $Links1, 1, 1))
MsgBox(0,'Max String value',_ArrayMax( $Links1, 0, 1))
MsgBox(0,'Max Numeric value',_ArrayMax( $Links1, 1, 1))
MsgBox(0,'Max Numeric value',_ArrayMax( $Links1, 1, 0))
MsgBox(0,'Max Numeric value',_ArrayMax( $Links1, 0,0))
It doesn't give me the 3 :ph34r:

What am i doing wrong?

Edited by Noobster24
Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc.
Link to comment
Share on other sites

  • Moderators

UBound() doesn't work for you?

Dim $Links1[4]
$Links1[0] = 'hi'
$Links1[1] = 'hadf'
$Links1[2] = 'adsfdsfhi'
$Links1[3] = 'dfljaleuhi'
MsgBox(64, 'Info', 'The total elements are: ' & UBound($Links1) - 1)

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

Damn, you're a genious right? :lmao:

Yeah, my genious plaque is right next to my jerk of the year award :geek::ph34r: Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...