Deleting multiple rows using a loop

Hello,
I'll do my best to explain my problem.
I have a list with several lines, "listLines."
In another list, I have the indexes of the lines to delete from the "listLines" list, but when I loop through it, it doesn't work.

In "listeTampon", there are the indexes of the lines to delete in the "ListeLigne" list

You have to delete from the greatest index first in descending order, because lists collapse when you remove items.

For code samples, post an aia export.

Hello,

I do have a list in descending order. I tested it with a checklist, and it works.
As soon as I try it automatically, it won't work anymore.

Post data and source we can run

Thanks in advance for your help.
Here's the project.
It's on the "LesPlans" screen.
In short, I'm trying to create a sort of plan with lines in a canvas. And when you click on the trash can and press the "valider" button, it deletes the lines that have the coordinates of the "trash can" sprite.

I hope my explanation is clear enough.

Thanks again for your help.

Harpe4SaisonV2.aia (439.2 KB)

There's a bit to tackle in your code, so I will break it down into bite sized bite.


It looks like you are using procedure parameters as local variables.

If you want local variables, pull in an init local variable block and use its blue mutator button to add as many local variables as you need. (5?)

This code sequence will lead to grief.
image
Your 4 elements are numbers, and JOINing them will result in a nonunique string of digits.
If you want a text representation of a 4 number list for a ListView Element, use the
JOIN With Separator ',' block, to turn a list into a comma delimited string.
Reverse that with the Split at ',' block to recover the 4 item list of coordinates.

If you use this text representation of each line as a key in a dictionary, with value TRUE for the existence of that line in a plan, you can represent each plan as a dictionary, with the keys of that dictionary all ready formatted as ListView Elements.
Deletion of a line from such a dictionary would then be just removing that key/value from the dictionary.
dictionaries_delete_pair

This approach avoids getting tangled up with list indexes, since it works entirely by value.

Hello,
I understand what you mean, but how can I get around this problem?
What I'm trying to do is, when the sprite retrieves the coordinates where it is located, it should check if there are any coordinates that are exactly the same, and if so, it should delete them from the list.

Sorry, but I'm just starting out and I'm going through the "trial and error" process.

You don't have to delete list items in place.

There is an advanced list filter block you can use to generate a filtered list to your taste. Then just swap in the filtered copy.

https://ai2.appinventor.mit.edu/reference/concepts/pholo.html