PushListPosition

List command

Syntax

Remembers the current element on a stack, so that PopListPosition() can come back to it later.

PushListPosition(<list>())

Parts

<list>A list declared with NewList, written with its empty parentheses: scores().

Good to know

  • Returns nothing: write it on its own line.
  • It remembers the element itself, not its position: elements added or moved before it do not matter.
  • Each list has its own stack. Several pushes are undone in reverse order.
  • With no current element, it remembers that: the matching pop leaves no current element.
  • Typical use: save the cursor, walk the list with FOREACH or a search, then restore it.

Example

NewList a.integer()FOR k = 1 TO 4  AddElement(a())  a() = k * 10NEXTSelectElement(a(), 1)PushListPosition(a())FirstElement(a())InsertElement(a())a() = 5PopListPosition(a())Console(Str(a()) + " at " + Str(ListIndex(a())))   ' 20 at 2
In the manual : Arrays, lists and maps