Sign in to follow this  
Followers 0
Kickassjoe

[Solved]Passing an Array to a UDF?

1 post in this topic

#1 ·  Posted (edited)

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.

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