How to delete an element of a Multidimensional Array

Hi Team!

I have a Multidimensional Array which I store, several data.

Example:
Name of Array : ReDim Invoices(NumberofInvoices, 4)
//Where:
NumberofInvoices: Number of “rows”
4: number of “columns”

UUID | DownloadLink | Year | Emitter | Receiver | ValidationStatus

So, for store data on each column I do:
For i as Integer = 0 to NumberofInvoices -1
Invoices(i,0) = UUID(i)
Invoices(i,1) = Links(i)
Invoices(i,2) = Receiver(i)
Invoices(i,3) = Emitter(i)
Invoices(i,4) = ValidSts(i)
Next i

And it works.

So, then I use the data of the “Invoices” Array, in order to download the data of every link of the array.

As This:
For z As Integer = 0 to Ubound(Invoices, 1)-1
DownInvoice(Invoices(z,1),Invoices(z,0),Invoices(z,3),Invoices(z,4))

Invoices(z,0) = ""
Invoices(z,1) = ""
Invoices(z,3) = ""
Invoices(z,4) = ""

Next z

As you can see After execute my method “Downvoice” I free memory, Asigning “” to each column, But I consider that would be great idea If I could delete one row or element in the array, after processing it, but I don’t have Idea how to do that.

I know how to do that on simple arrays as this:
Array.remove(4) ///Where: 4 is the name of the element of the array to remove.

Thanks

You will make things much easier if you replace the multi-dimensional array with an Invoice class with properties. You can then use a single-dimensional array to hold Invoices. More, it will be much easier to add properties in the future if needed, and auto-complete will be your friend.

To answer the question you asked, I don’t think there is a way to remove a single element without creating a new array and copying the remaining elements.

[quote=298517:@Kem Tekinay]You will make things much easier if you replace the multi-dimensional array with an Invoice class with properties. You can then use a single-dimensional array to hold Invoices. More, it will be much easier to add properties in the future if needed, and auto-complete will be your friend.

To answer the question you asked, I don’t think there is a way to remove a single element without creating a new array and copying the remaining elements.[/quote]

YES, I have classes to process the invoices.

The idea to that array is to do webscrapping of certain website.

Extract this elements, columns and rows of a table on this website.
For do this I use an HTMLViewer and a little bit of Javascript.
So when I finish ripping all the data on the table I load all this data on the multidimensional array.

Once is loaded data on Multidimensional Array, I proceed to download every link (element) on the array.

Once downloaded I need to freeing memory

Redim Invoices ( -1) .

You clear all the array in one operation. You would do that of course when you are done processing all the items in the array.

I also would store invoices in a sqlite database, and not in memory … would be easier to handle

[quote=298523:@Louis Desjardins]Redim Invoices ( -1) .

You clear all the array in one operation. You would do that of course when you are done processing all the items in the array.[/quote]
Yes, I do this at the end of process. But I wonder if is it possible to remove 1 element of the array after processing it.
Thanks :smiley:

Edit: You totally missed the point, emphasized the quote for the tl;dr

[quote=298525:@Gerardo García]Yes, I do this at the end of process. But I wonder if is it possible to remove 1 element of the array after processing it.
Thanks :D.

Well, I do: Redim Invoices(-1,-1)([/quote]

convert you multi-dimensional array to an array of classes or structures… don’t make it more difficult than need be

Yeah, As you tell it, It seems more simple And doing this I don’t waste memory.

memory is not an issue here… but you have been given solutions, take them, or don’t take them

(an array of simple classes will take up LESS memory than a multi-dimensional array, I believe)

+1.

Now, there is another way to “delete” an item from an array: include in the structure or in the dimensions, a “delete flag”. Check the delete flag before using an element. It is not relevant to the OP, but can be useful in other situations.

I can endorse the idea of converting the data structure from a multi-dimensional array to an array of classes.

To highlight a statement from the online documentation:
“Most of the array methods are not supported for multi-dimensional arrays.”

When we were first using Xojo, we implemented a multi-dimensional array to represent a data structure. We then ran into problems trying to pass the multi-dimensional array as a parameter to a method (along with other problems). Converting to a one-dimensional array of classes/objects cleaned things up nicely. As a bonus, the code was a lot easier to maintain.