PushListPosition()
Syntax
PushListPosition(List())Description
Remembers the current element (if any) of the list so it can later be restored using PopListPosition(). The position is remembered on a stack structure, so multiple calls to this function are possible.
Parameters
List() The name of your list variable, created with the NewList function. You must include the brackets after the list name.
Return value
None.
Remarks
This function can be used to remember the current element, so an iteration can be made over the list using NextElement() or ForEach and the current element can be restored after the iteration using PopListPosition(). Multiple calls can be made to this function, as long as each is balanced with a corresponding PopListPosition() call later.
Note: It is not allowed to delete an element that is a remembered current element using the DeleteElement() or ClearList() function. This may result in a crash when PopListPosition() is called because the elements memory is no longer valid.
Example
NewList Numbers() AddElement(Numbers()): Numbers() = 1 AddElement(Numbers()): Numbers() = 2 AddElement(Numbers()): Numbers() = 5 AddElement(Numbers()): Numbers() = 3 AddElement(Numbers()): Numbers() = 5 AddElement(Numbers()): Numbers() = 2 ; A simple duplicate elimination using a nested iteration ; ForEach Numbers() Value = Numbers() PushListPosition(Numbers()) While NextElement(Numbers()) If Numbers() = Value DeleteElement(Numbers()) EndIf Wend PopListPosition(Numbers()) Next ForEach Numbers() Debug Numbers() Next
See Also
PopListPosition(), SelectElement(), ChangeCurrentElement(), NextElement(), PreviousElement(), ForEach
Supported OS
All