ChangeCurrentElement()
Syntax
ChangeCurrentElement(List(), *NewElement)Description
Changes the current element of the specified list to the given new element. This function is very useful if you want to "remember" an element, and restore it after performing other processing.
Parameters
List() The name of the list, created with the NewList function. You must include the brackets after the list name. *NewElement The new element to set as the current element for the list. The element must be a pointer to another element which exists in this list. You should get this address by using the @ operator on the list name and not through any other method.
Return value
None.
Example: Simplified
*Old_Element = @mylist() ; Get the address of the current element ResetList(mylist()) ; Perform a search for all elements named While NextElement(mylist()) ; "John" and change them to "J" If mylist()\name = "John" mylist()\name = "J" EndIf Wend ChangeCurrentElement(mylist(), *Old_Element) ; Restore previous current element (from before the search)
Example: Complete
NewList myList() AddElement(myList()) myList() = 100 AddElement(myList()) myList() = 200 *element = @myList() AddElement(myList()) myList() = 300 Debug myList() ; Displays 300 (last element) ChangeCurrentElement(myList(), *element) ; Restore list position Debug myList() ; Displays 200 ForEach myList() If @myList() = *element Debug "element: " + myList() ; Displays "element: 200" EndIf Next
See Also
SelectElement(), PushListPosition(), PopListPosition()
Supported OS
All