for¶
Syntax¶
Parameters¶
<variable>- The name of a numeric variable defined earlier in the program.
<list>- An expression that is or returns a list to iterate over.
<statement>- A valid FRED statement, such as an action or an assignment.
Description¶
Iterate over a list.
The variable is an iterator that sequentially takes on each value from the provided list. When execution begins, the iterator is assigned to the first value from the list, then the statements within the block are executed; afterward, the iterator moves to the second value, executes the statements again, and continues this pattern until every element in the list has been processed.
Examples¶
# i is a shared numeric variable defined previously
for(i,list(1, 2, 3)) do {
print(i) # Prints 1, then 2, then 3
}