Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
For each doesn't release all forms?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
01241310
Message ID:
01484225
Vues:
66
>So, what is the solution to the problem of removing item from collection while iterating through it if I don't want to start from last item?
>
>Update. I think if I will always remove the first item
>
>for lnI = 1 to Collection.Count
>   oItem[1].Remove()
>next
>
>will work

It will work but usually you will have a conditional removal and then this code will not be useful (You could've use Remove(-1) to remove all items). You could always use a two pass procedure, in the first pass you determine the items you want to delete and store its keys in an auxiliary object (another collection, a cursor an array etc) then your second pass would be to scan that auxiliary object and use the keys to remove the items from the collection.
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform