Mison Posted February 10, 2010 Share Posted February 10, 2010 Hi all, I have a question. How to declare an array with multiple array dimension,dynamically? My current implementation is: #include <Array.au3> $Array = ArrayCreate(2,2) _ArrayDisplay($Array) Func ArrayCreate($dim1=0, $dim2=0, $dim3=0, $dim4=0) Local $tempArray[1] Switch @NumParams Case 1 ReDim $tempArray [$dim1] Case 2 ReDim $tempArray [$dim1][$dim2] Case 3 ReDim $tempArray [$dim1][$dim2][$dim3] Case 4 ReDim $tempArray [$dim1][$dim2][$dim3][$dim4] EndSwitch Return $tempArray EndFunc And it works pretty well, but could be very long, as the number of dimensions increased. Is there any better way to do it? I'm thinking something like Eval() or Execute(), but they didn't work. Hi ;) Link to comment Share on other sites More sharing options...
MvGulik Posted February 10, 2010 Share Posted February 10, 2010 (edited) whatever Edited February 7, 2011 by MvGulik "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ... Link to comment Share on other sites More sharing options...
Mison Posted February 10, 2010 Author Share Posted February 10, 2010 Thanks MvGulik. Just as I thought. Would you mind if I use your code for my future project? Credit will be given, of course. Hi ;) Link to comment Share on other sites More sharing options...
MvGulik Posted February 10, 2010 Share Posted February 10, 2010 (edited) whatever Edited February 7, 2011 by MvGulik "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ... 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