Sign in to follow this  
Followers 0
Husker_Jason

_ArraySort gives ByRef Error

3 posts in this topic

I'm trying to write a function that takes a 2D Array and a certain Index to calculate a median of that index

Func _ArrayMedian ($vaArray, $viIndex)
    ; Returns the median of the column of data asked for
    ; Assumes Array sends array dimentions in [0][0] = Rows [0][1] = Columns
    Local $X                                            ; Counter
    Local $vsSum                                        ; Sum of data
    _ArraySort(0, 0, 1, $viIndex)                   ; Sort Array by the index
    If $vaArray[0][0] = 0 Then                          ; Array empty
        Return 0
    ElseIf Mod($vaArray[0][0], 2) = 0 Then                  ; Array has even number
        Return ($vaArray[int(($vaArray[0][0] / 2))][$viIndex] + $vaArray[int($vaArray[0][0] / 2) + 1]][$viIndex) / 2
    Else                                                ; Array has odd number
        Return $vaArray[int($vaArray[0][0] / 2) + 1][$viIndex]
    EndIf
EndFunc

When I do a Syntex check  I get the error

"error: _ArraySort() called with Const or expression on ByRef-param(s)" when I call the _ArraySort() function.

I guess I don't understand what ByRef means so have no idea how to pass my $viIndex value through the function so it looks at the right column. Anyone able to educate me on this?

Thanks

 

Share this post


Link to post
Share on other sites



WOW, I feel like a moron now.  Looked at that for an hour.  Always good to have a second set of eyes.

 

Thanks.

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