PushListPosition()
语法
PushListPosition(List())概要
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.
参数
List() The name of your list variable, created with the NewList function. You must include the brackets after the list name.
返回值
无.
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.
示例
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
参阅
PopListPosition(), SelectElement(), ChangeCurrentElement(), NextElement(), PreviousElement(), ForEach
已支持操作系统
所有