Jump to content

Deleting item from multidimensional array


DickG
 Share

Recommended Posts

I am adding items to an array like this:

For $i = 0 To $rows

;Code that generates values goes here.

;Add item to array.

$FileList[$i][0] = <some value for 1st column>

$FileList[$i][1] = <some value for 2nd column>

Next

I then need to delete row 0 because it is always empty (values are 0) no matter how I try to prevent it.

I tried using _ArrayDelete($FileList, 0), but it does not work It apparently doesn't see this as an array. I am not using a listview for this.

Is there a way to delete an item in this type of array?

Dick

Link to comment
Share on other sites

I am adding items to an array like this:

For $i = 0 To $rows

;Code that generates values goes here.

;Add item to array.

$FileList[$i][0] = <some value for 1st column>

$FileList[$i][1] = <some value for 2nd column>

Next

I then need to delete row 0 because it is always empty (values are 0) no matter how I try to prevent it.

I tried using _ArrayDelete($FileList, 0), but it does not work It apparently doesn't see this as an array. I am not using a listview for this.

Is there a way to delete an item in this type of array?

Dick

If you are using the current version of AutoIt, then _ArrayDelete() works fine with 2D arrays. It will only delete rows (first index), not columns (second index). If you need to delete a column, you will have to run a loop to copy higher numbered column data down and then ReDim the second index to the new size.

:mellow:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Oops, I forgot to mention which version I'm using. I am using 3.2.10.

I tried v3.2.12, but along with the new SciTE version to match, I was getting errors. So I went back to 3.2.10 and the previous SciTE version.

If I don't/can't use _ArrayDelete(), what other method can be used to remove a row from a multidimensional array? [no need to delete a column].

If you are using the current version of AutoIt, then _ArrayDelete() works fine with 2D arrays. It will only delete rows (first index), not columns (second index). If you need to delete a column, you will have to run a loop to copy higher numbered column data down and then ReDim the second index to the new size.

:mellow:

Link to comment
Share on other sites

Oops, I forgot to mention which version I'm using. I am using 3.2.10.

I tried v3.2.12, but along with the new SciTE version to match, I was getting errors. So I went back to 3.2.10 and the previous SciTE version.

If I don't/can't use _ArrayDelete(), what other method can be used to remove a row from a multidimensional array? [no need to delete a column].

Just open the 3.2.12.1 version of Include\Array.au3 and modify that code as required to do what you want.

What kind of errors did you get migrating from 3.2.10.0 to 3.2.12.1? Other than some changes to RunAs() and the #include file structure, which is easy to fix, it shouldn't be hard to update your code.

:mellow:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...