Shastaman Posted March 18, 2008 Share Posted March 18, 2008 Trying to pass an array to a function, but it doesn't like function declaration. Realize the example declares it as global but I want to pass in different arrays so I don't want to specify specific array name in function. Dim $bob[2] $bob[0] = "Hey 1" $bob[1] = "Hey 2" SendArray($bob) Func SendArray($funcArray[]) MSgbox(0, "funcArray 0 in function", $funcArray[0]) MSgbox(0, "funcArray 1 in function", $funcArray[1]) EndFunc Link to comment Share on other sites More sharing options...
Nahuel Posted March 18, 2008 Share Posted March 18, 2008 Dim $bob[2] $bob[0] = "Hey 1" $bob[1] = "Hey 2" SendArray($bob) Func SendArray($funcArray) MSgbox(0, "funcArray 0 in function", $funcArray[0]) MSgbox(0, "funcArray 1 in function", $funcArray[1]) EndFuncIt just has to work. Remember that arrays are variables too. So no need for the "[]" when passing the whole array. Link to comment Share on other sites More sharing options...
Zedna Posted March 18, 2008 Share Posted March 18, 2008 One note: Consider ByRef for speed optimization reason. Func SendArray($funcArray) Func SendArray(ByRef $funcArray) If you don't use ByRef then input array is COPIED to local variable (param) If you use ByRef then no COPY is performed. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Shastaman Posted March 18, 2008 Author Share Posted March 18, 2008 Thanks. I thought I would have to specify I was passing an array but, likely due to the variant type, it doesn't need this specificity. Thanks all Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now