|
| Deleting Elements In An Array |
| Iniciado por guest, 23,nov. 2015 15:40 - 3 respuestas |
| |
| | | |
|
| |
| Publicado el 23,noviembre 2015 - 15:40 |
Hi All
I am wanting to loop through a structured array and delete a line based on a value in one of the fields in the structure. Is it in order to use a for each rec of the array and then use:
ArrayDelete(myArray,CurrentElement)?
Is this the correct approach?
Cheers André |
| |
| |
| | | |
|
| | |
| |
| Publicado el 23,noviembre 2015 - 16:03 |
André
According to the Help the 'CurrentElement' subscript can only be used with associative arrays so it would seem not.
Probably need to increment an integer counter for each loop of the array and use ArrayDelete(myArray,nCounter). Followed by decreasing the count value by 1 'nCounter --' to keep the counter in step as the ArrayDelete is effective immediately.
Have not tried this so I would run a test first - In debug to see what happens. It is possible that if a row is removed from the array the next read could in fact skip a row. |
| |
| |
| | | |
|
| | |
| |
| Publicado el 23,noviembre 2015 - 16:25 |
Hi André,
Out of my head something like: FOR EACH Element, Index OF MyArray FROMEND IF Element.MyValue = Something THEN ArrayDelete(MyArray, Index) END END Cheers,
Peter Holemans |
| |
| |
| | | |
|
| | |
| |
| Publicado el 23,noviembre 2015 - 19:52 |
Thanks Peter - you have a good head - exactly what I was looking for.
Cheers André |
| |
| |
| | | |
|
| | | | |
| | |
|