DeleteElement()

Syntax

*Result = DeleteElement(List() [, Flags])
Description
Remove the current element from the list. After this call, the new current element is the previous element (the one before the deleted element). If that element does not exist (in other words, you deleted the first element in the list) then there is no more current element, as it will be before the first element, like after a ResetList().

Parameters

List() List() - The name of your list variable, created with the NewList function. You must include the brackets after the list name.
Flags (optional) If this parameter is set to 1 and the first element is deleted, the new current element will be the second one. This flag ensures there will be always a valid current element after a delete as long as there are still elements in the list.

Return value

Returns the memory address of the new current element of the list. If the list has no current element after the deletion, the result is 0.

Example

  NewList people.s()

  AddElement(people()) : people() = "Tom"
  AddElement(people()) : people() = "Dick"
  AddElement(people()) : people() = "Harry"
  AddElement(people()) : people() = "Bob"

  FirstElement(people())
  DeleteElement(people(), 1)
  MessageRequester("Information", "First person in list is "+people(), #PB_MessageRequester_Ok)

  LastElement(people())      ; Moves to "Bob"
  PreviousElement(people())  ; Moves to "Harry"
  DeleteElement(people())    ; And deletes him. there is an element before Harry, so it becomes the current
  MessageRequester("Information", "Current person in list is "+people(), #PB_MessageRequester_Ok)

See Also

AddElement(), InsertElement(), ClearList()

Supported OS

All

<- CountList() - List Index - FirstElement() ->