NextElement()

Syntax

Result = NextElement(linkedlist())
Description
Moves from the current element to the next element in the list, or onto the first element if you have previously called ResetList()

Parameter:
linkedlist() - The name of your linked list variable, created with the NewList command. You must specify the brackets after the list name.

Return value:
The value returned by this command can be used to show whether the next element exists or not (it will not exist if you are at the end of the list). If the next item exists, this command will return a value which is not equal to zero. If the next element does not exist then it will return a value of zero.

Advanced users only:
The value that this command returns is a pointer to the next element or zero if the next element does not exist. The structure of each element is shown below:
  Structure Element
    *Next.Element        ; Pointer to next element in list or zero if at last element
    *Previous.Element    ; Pointer to previous element in list or zero if at first element

    ; The users data type which the list was created with will follow
    ; those two variables (which means the user data can be found at
    ; the address of the new element + 8
  EndStructure
You should not change the pointers at the start of the elements as this will break the structure of the list, leading to all sorts of problems.

Example:
  NewList scores.w()

  For i=1 To 10
    AddElement(scores())
    scores() = 100 - i
  Next

  ResetList(scores())
  While NextElement(scores())
    ; This is OK since the first call to NextElement() will move the current element to the first item in the list
    MessageRequester("Score", Str(scores()), #PB_MessageRequester_OK)
  Wend

Supported OS

All

<- ListIndex() - LinkedList Index - PreviousElement() ->