Jump to content

Recommended Posts

Posted

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 ;)

Posted

Thanks MvGulik. Just as I thought.

Would you mind if I use your code for my future project? Credit will be given, of course. :D

Hi ;)

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
×
×
  • Create New...