vrsrinivas2000

Array

8 posts in this topic

#1 ·  Posted

Hi,

1) How to declare 3d array with external excel table variables (3 dimensional table).

2) How to change the 2d to 3d array (Already used 2d array in the scrip)

Share this post


Link to post
Share on other sites



#2 ·  Posted

According to the help file, you cannot resize the dimensions of an existing array and retain the data in it.  Per the help file, 

Quote

The ReDim keyword is similar to Global/Local, except that ReDim preserves the values in the array instead of removing the values while resizing an array.
The number of dimensions must remain the same, or the old array will be forgotten during the ReDim.
The array will retain the scope (Global or Local) that it had prior to resizing.

So you'll probably have to create a new 3D array and populate as needed, or re-write your script to make the array 3D from the get go.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

4 hours ago, vrsrinivas2000 said:

2) How to change the 2d to 3d array (Already used 2d array in the scrip)

You can do this using _PreDim() without any data loss. The function was designed for this very purpose. See ArrayWorkshop in my signature below.

#include <ArrayWorkshop.au3>

Local $aArrayXD = [[1,2],[3,4]] ; 2D array
_PreDim($aArrayXD, 3) ; becomes a 3D array

After this you can increase the size of the third dimension using (the more standard) ReDim.

Alternatively, you can attach 2D arrays in the 3rd dimension using _ArrayAttach(): think of this as stacking spread sheets in a pile.

Edited by czardas
1 person likes this

Share this post


Link to post
Share on other sites

#4 ·  Posted

Moved to the appropriate forum, as the DEV forum specifically states:

Quote

Do not create AutoIt-related topics here

 


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Yeah, I wondered about that. It shows how little I use Excel. It should have 3D grids though, and you should be able to zoom into the matrix using the mouse wheel. :D

Edited by czardas

Share this post


Link to post
Share on other sites

#7 ·  Posted

28 minutes ago, czardas said:

Yeah, I wondered about that. It shows how little I use Excel. It should have 3D grids though, and you should be able to zoom into the matrix using the mouse wheel. :D

Beam me up, Scotty!


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

It just seems like an obvious way to organize certain types of data.

Edited by czardas

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