ForEach : Next

ForEach List() Or Map()
Next [List() Or Map()]
ForEach loops through all elements in the specified list or map starting from the first element up to the last. If the list or the map is empty, ForEach : Next exits immediately. To view all commands used to manage lists, please click here. To view all commands used to manage maps, please click here.

When used with list, it's possible to delete or add elements during the loop. As well it's 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 skipped.

Example: list

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

Example: Map

  NewMap Country.s()

  Country("US") = "United States"
  Country("FR") = "France"
  Country("GE") = "Germany"

  ForEach Country()
    Debug Country()