Jump to content

arrays as parameters


Recommended Posts

Hi,

I'd like to perform something like this :

Func BuildObject(ByRef $array)
    $array[0] = "0"
    $array[1] = "1" 
EndFunc

Func _Main()
    Local $array
    BuildObject($array)
    _ArrayDisplay($array)
EndFunc

In other words, I'd like an object to be declared at a higher level in the code, and be "built" by a function that would act as a factory. The dimensions of the object are not know at declaration time. They are known only by the factory.

The code above is not correct in the autoIT syntax. Can you tell me how to make it correct?

Edited by MonsieurOUXX
Link to comment
Share on other sites

OK, my mistake, the code below works :

Func BuildObject1D(ByRef $array)
    Local $_array[2] = ["0", "1"]
    $array = $_array
EndFunc

Func BuildObject2D(ByRef $array)
    Local $_array[2][2] = [["0", "_0"], ["1","_1"]]
    $array = $_array
EndFunc

Func _Main2()
    Local $array
    BuildObject1D($array)
    BuildObject2D($array)
    _ArrayDisplay($array)
EndFunc

I'll come back with a more accurate question

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