Jump to content

reDim only 1 of multi dimension array


 Share

Recommended Posts

Hi All,

I'm pretty sure I know the answer but I want to know if i missed something.

I want to know if you can reDim only 1 dimension in a multi dimensional array without having to state the size of the other dimensions and have them stay as they are.

In several areas of my script i will have to increase either the 1st or 3rd dimension and I currently will use ubound to detect the sizes they are at, but i only need to really check the one i want to change (as the others will be checked when they may need to be changed).

so say I start out with:

aArray[10][5][10]

then my script reDims aArray[11][5][10]

now i want to reDim the 3rd dimension, is there a way to code it so

aArray[as-is][as-is][11] (only changing 3rd dimension)

or is the only way to do this by reading all current sizes (via Ubound) and place these values in the dimensions I wish to stay as-is.

I know using Ubound is not a hassle i only ask this because i wish to try to learn to get better and keep my code as simple as possible/needed.

Thx for any assistance,

A.B.Ames

Link to comment
Share on other sites

I just tried this, which didn't work:

Local $Array[1][2][3]
ReDim $Array[][][4]

so it looks like the only way to resize one dimension of a multi-dimensional array is to restate the other dimensions using UBound().

Link to comment
Share on other sites

I just tried this, which didn't work:

Local $Array[1][2][3]
ReDim $Array[][][4]

so it looks like the only way to resize one dimension of a multi-dimensional array is to restate the other dimensions using UBound().

Thx for reponding LxP,

Yeah i tried a few things and that was one too.

Though (after experimenting) i did find that I can use Ubound within the ReDim statment as shown below:

Dim $testArray[5][10][15]
$var = 20
ReDim $testArray[Ubound($testArray,1)][Ubound($testArray,2)][$var]
;--- testing results below
$1dim = UBound($testArray,1); size of Dimension 1
$2dim = UBound($testArray,2); Size of Dimension 2
$3dim = UBound($testArray,3); Size of Dimension 3
MsgBox(0, "Test Array Size", "1st DIM = " & $1dim & @LF & "2nd DIM = " & $2dim & @LF & "3rd DIM = " & $3dim)

I was unaware that this was possible as i had been using variables with the ubound results, but this seems much easier and as of yet i have found no negative results (though someone may know of some).

Again thx for your assistance

A.B.Ames

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...