Foreach - Function Summary
Evaluates a block for each value(s) in a series.
foreach word data body
word - Word or block of words to set each time (will be local) (must be: get-word word block)
data - The series to traverse (must be: series)
body - Block to evaluate each time (must be: block)
For every value in a series, such as a block or string, this function will evaluate a block using a variable that holds that value.
For example, the series below is a block of city names. For each name in that block, the PRINT function will be evaluated. The CITY variable holds the name of the city each time.
This also works for strings. Each character of the string will be printed below:
The second argument can also be a block of words to get multiple values at the same time from the block: