Jump to content

_MaxArrayIndex on n-dimensional arrays


Recommended Posts

Not a big deal, but I have a 2-dimensional array, currently 10 x 4 (the 4 being constant for each first element) I wondered if it was possible to compute the max array element for the first subscript?

Given that I am populating the array in my code it isn't a big deal (I have just declared a constant that I alter when I add rows to the array) but it kindof "offends my programmers sensibilities" to not be able to determine the max first subscript programmatically.

Link to comment
Share on other sites

Not a big deal, but I have a 2-dimensional array, currently 10 x 4 (the 4 being constant for each first element) I wondered if it was possible to compute the max array element for the first subscript?

Given that I am populating the array in my code it isn't a big deal (I have just declared a constant that I alter when I add rows to the array) but it kindof "offends my programmers sensibilities" to not be able to determine the max first subscript programmatically.

have a look at UBound().

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

have a look at UBound().

UBound returns the size of an array dimension. I don't think that's what he means. He means something like this, which does not work:

; this code gives an error in Array.au3 because _arrayMax(Index) wants a single-dimensioned array.
#include <Array.au3>

Dim $testArray[3][3]

For $x=0 To 2
    For $y=0 To 2
        $testArray[$x][$y]=4*$x+8*$y
    Next
Next

MsgBox(0,"test","Biggest value in testArray - "&_ArrayMax($testArray))

I wanted to do this too some time ago, but since it did not work, I created a workaround by using a nested for-loop for both dimensions and checking myself (but those were 2 dimensions with less than 50 elements, and search speed was not a big issue so I did not bother to look for a more professional approach).

If anyone has better ideas about this then I would like to know too :whistle:

/edit: typo

Edited by SadBunny

Roses are FF0000, violets are 0000FF... All my base are belong to you.

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...