PushMapPosition()

Syntax

PushMapPosition(Map())
Description
Remembers the current element (if any) of the map so it can later be restored using PopMapPosition(). The position is remembered on a stack structure, so multiple calls to this function are possible.

Parameters

Map() The map to use.

Return value

None.

Remarks

This function can be used to remember the current element, so an iteration can be made over the map using NextMapElement() or ForEach and the current element can be restored after the iteration using PopMapPosition(). Multiple calls can be made to this function, as long as each is balanced with a corresponding PopMapPosition() call later.

Note: It is not allowed to delete an element that is a remembered current element using the DeleteMapElement() or ClearMap() function. This may result in a crash when PopMapPosition() is called because the elements memory is no longer valid.

Example

  NewMap Numbers()
  Numbers("A") = 1
  Numbers("B") = 2
  Numbers("C") = 5
  Numbers("D") = 3
  Numbers("E") = 2
  Numbers("F") = 5

  ; A simple duplicate elimination using a nested iteration
  ;
  ForEach Numbers()
    Value = Numbers()
    PushMapPosition(Numbers())
    While NextMapElement(Numbers())
      If Numbers() = Value
        DeleteMapElement(Numbers())
      EndIf
    Wend
    PopMapPosition(Numbers())
  Next

  ForEach Numbers()
    Debug Numbers()
  Next

See Also

PopMapPosition(), FindMapElement(), NextMapElement(), ResetMap(), ForEach

Supported OS

All

<- PopMapPosition() - Map Index - ResetMap() ->