Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

MaxSpa instruction


Jackson.Lopes Aug 31, 2016 02:51 PM

Hey Guys. Morning.

I have a  question that I think will be easy for you answer  me:

Is it possible  to use the MaxSpa function to get a Max value from an array two dimensions, for exemple: X(5,2)? If so, how the instruction will evaluate the Max and how the values will be returned to me ?

Regards.


GTProdMgr Aug 31, 2016 03:47 PM

Internally, multi-dimensional arrays are often considered as "lengthy" single dimensional arrays. So I would try this:

--

Public X(5,2)

Public myMax(2)

...

MaxSpa(myMax(),10,X())

--

The swath of 10 is chosen by counting up all the elements in the multi-dimensional array. (5x2)

I would test it out with some test data first to make sure it works properly. If it doesn't work, then my guess is that there isn't currently a way to do this.

If it doesn't work, I think the easiest solution would be to dump the values of your multi-dimensional array into a single-dimensional array and run MaxSpa on that.

It would be something like this (I haven't tested it out):

--

Public X(5,2)

Public Combo(10)

Public myMax(2)

Dim I as Long

Dim J as Long

Dim N as Long

N = 1

For I = 1 To 5

  For J = 1 to 2

    Combo(N) = X(I,J)

    N += 1

  Next 'J

Next 'I

MaxSpa(myMax(),10,Combo())


Jackson.Lopes Aug 31, 2016 04:58 PM

Hey.

I've just found out how it works.

When using MaxSpa  to return the Max value in a two dimensions array, it will give us the max value and its exact location. For exemple:  Pretend you have an array  X(5,2) . If the Max value is in position X(4,2), Dest1 will be Max value and Dest 2 will return the number 8 as its position. The instruction will treat the two dimensions array like if it was a one dimension array.

Thanks for your help

Best regards.

Log in or register to post/reply in the forum.