Sign in to follow this  
Followers 0
MonsieurOUXX

arrays as parameters

3 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

OK, forget about my posts, I made a mistake with an index out of bounds. Shame on me.

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