ForEach : Next


Syntax
ForEach LinkedList()
  ...
Next
Description
ForEach loops through all elements in the specified linked list starting from the first element up to the last. If the list is empty, ForEach : Next exits immediately. To view all commands used to manage lists, please click here.

As the loop is only ended, when the last element (by position, not by the number) is reached, its possible to delete or add elements during the loop. As well its allowed to change the current element with ChangeCurrentElement(). After one of the mentioned changes the next loop continues with the element following the current element.

With the Break command its possible to exit the ForEach : Next loop at any moment, with the Continue command the end of the current iteration can be skiped.

Example:

  NewList Number()
  
  AddElement(Number())
  Number() = 10
    
  AddElement(Number())
  Number() = 20
    
  AddElement(Number())
  Number() = 30
    
  ForEach Number()
    Debug Number() ; Will output 10, 20 and 30
  Next