EnglishРусский  
The project is closed! You can look at a new scripting language. It is available on GitHub.
Also, try our open source cross-platform automation software.

Ads

Installer and installation software
Commercial and Freeware installers.

foreach statement

The foreach loop is used to work with objects containing some number of elements. The type of an object must have the first, next, eof methods. See more details on the System type methods page. With the foreach construction, it is possible to go through all elements in the initial object.

You specify the name of the variable that will point to each next element after the foreach keyword. After that the object including the loop and then the body of the loop come separated with a comma. If the object contains elements of the numeric type, the index variable will contain values. If the object consists of items of the structural type, the index variable will point to each next element. If you change the index variable in this case, the corresponding element in the object will be changes as well.

arrstr names = %{"John","Steve","Laura", "Vanessa"}

foreach curname,names
{
   print("\( curname )\n")
}

Related links