Jump to content
Sign in to follow this  

Assigning arrays by reference

Recommended Posts


Arrays are such a versatile way of storing and manipulate data.

In Autoit you can have a Array of Arrays but there is, as fare as I know, a cavete. You can not assigne a sub array to a variable by reference.


#include <Array.au3>
Func GetSubArray(ByRef $rootArr, $arrID, ByRef $subArr)
  ;Use $arrID to locate the subArr, in this sample 0
   dim $index=0
  ;This will creata a copy of the array in $rootArr[0].
  ;Is it possible to assigne it by reference?
   $subArr = $rootArr[0]

dim $rootArr[2]
$rootArr[0] = _ArrayCreate("Item1","Item2","Item3")
dim $subArr
GetSubArray($rootArr, "SomeID", $subArr)
$subArr[0] = "Modified1"
_ArrayDisplay($subArr, "Retrived sub array")
_ArrayDisplay($rootArr[0], "Referenced array")

Have I missed how or is it not possible to assigne an array by reference to a new variable?

Would it be hard to implement? I'm asking since I feel the code sort of must be inside autoit allready since it suports ByRef in and out of the function.



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