# comparing multiple number values

## Recommended Posts

i have an array of numbers

whats the most efficient way of comparing all of them to find the largest number?

was trying to use a for loop for a faster/more efficient compare but cant figure out the logic

```For \$x = 1 To 4
If \$aINIs[\$x][1] > \$aINIs[\$x + 1][1] Then
\$largest = \$x
Else
\$largest = \$x + 1
EndIf
Next

msgbox(0,"", \$largest & " is the largest")```

thanks =)

Edited by gcue

##### Share on other sites

nevermind _arraymaxindex!

thanks =)

##### Share on other sites

what can i use for a multicolumn array? doesnt seem that _arraymaxindex supports more than one column

##### Share on other sites

If you wanted to do it in the least lines of Autoit code, you could probably just use _ArraySort and then check the last (or first, depending upon sort order) element for your value.

Of course, that method destroys the original order of your array, and behind the scenes is doing a ton more processing than is necessary. You were on the right track to begin with, with something like:

```\$largest = 0
For \$x = 1 To UBound(\$aINI, 1) - 1
If \$aINIs[\$x][1] > \$aINIs[\$x - 1][1] Then \$largest = \$x
Next
MsgBox(0,"", "Index " & \$largest & " is the largest, with a value of: " & \$aINIs[\$largest][1])```

##### Share on other sites

thanks for the response spiff

that doesn't seem to be working properly though..

it says index 5 value is the largest when its not

http://www.postimage.org/image.php?v=gxyZHBA

Edited by gcue

##### Share on other sites

```\$largest = 0
For \$x = 0 To UBound(\$aINI, 1) - 1
If \$aINIs[\$x][1] > \$largest Then \$largest = \$x
Next
MsgBox(0,"", "Index " & \$largest & " is the largest, with a value of: " & \$aINIs[\$largest][1])```

Oops,you're right, \$largest needs going thru array indexing.

Edited by jchd

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

##### Share on other sites

Pardon me, the Mark 1 Eyeball failed me.

```\$largest = 0
For \$x = 1 To UBound(\$aINIs, 1) - 1
If \$aINIs[\$x][1] > \$aINIs[\$largest][1] Then \$largest = \$x
Next
MsgBox(0,"", "Index " & \$largest & " is the largest, with a value of: " & \$aINIs[\$largest][1])```
Edited by Spiff59

works great!

thanks guys

## Create an account

Register a new account

×

• Wiki

• Back

• Git