Then it would be compatible with ListIndex():
If ListIndex(mylist) = 2 -> then SelectElement(mylist, 2) restore the saved position
If ListIndex(mylist) = 0 -> then SelectElement(mylist, 0) restore the saved position
If ListIndex(mylist) = -1 -> then SelectElement(mylist, -1) returns an error! But PushListPosition() and PopListPosition() can save and restore the position -1...
The position =-1 is a valid position in the PB linked list cosmos! ListIndex(), PushListPosition(), PopListPosition() can handle this position. But not SelectElement(). That is inconsistent.
This code shows, that a position of -1 can be saved and restored:
Code: Select all
NewList test()
AddElement(test()): test() = 4
AddElement(test()): test() = 5
AddElement(test()): test() = 6
; reset list and save the position
ResetList(test())
PushListPosition(test())
; select last element (2)
LastElement(test())
Debug ListIndex(test())
; restore position (-1)
PopListPosition(test())
Debug ListIndex(test())