NextElement

List command

Syntax

Moves the cursor to the next element and makes it current.

NextElement(<list>())

Parts

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

Returns

1 when it moved, 0 when there was no next element.

Good to know

  • From no current element after ResetList(), it goes to the first element. That makes ResetList() then WHILE NextElement(a()) a full walk.
  • Past the last element it returns 0 and leaves no current element. A PreviousElement() then goes back to the last one.
  • After FreeList(), the call stops the program with "BASIC list is not initialized".

Example

NewList a.integer()FOR k = 1 TO 4  AddElement(a())  a() = k * 10NEXTtotal = 0ResetList(a())WHILE NextElement(a())  total = total + a()WENDConsole(Str(total))   ' 100
In the manual : Arrays, lists and maps