Jump to content

[Solved]Passing an Array to a UDF?


Recommended Posts

How would I go about doing this?

ex:

_UseTheArray(_MakeAnArray())

Func _MakeAnArray()
    
    Dim $Array[5][5]
    
    For $x = 0 to 4
        For $y = 0 to 4
            $Array[$x][$y] = 1
        Next
    Next
    
    Return $Array
    
EndFunc

Func _UseTheArray($AnArrayHere)
    
    If NOT IsArray($AnArrayHere) Then
        Exit
    EndIf
    
    For $x = 0 to UBound($AnArrayHere) - 1
        For $y = 0 to UBound($AnArrayHere, 2) - 1
            $AnArrayHere[$x][$y] += 1
        Next
    Next
    
    _ArrayDisplay($AnArrayHere)
    
EndFunc

Maybe I'm just returning the array wrongly?

EDIT: Seems to be working, guess there's just an error somewhere in my code that I'm not seeing, I'll have a look at it

EDIT2: Forgot a -1 on my UBound() :/, fixed

Edited by Kickassjoe

What goes around comes around... Payback's a bitch.

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