Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
For each doesn't release all forms?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01241310
Message ID:
01484225
Views:
67
>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform