Loops are often coded with "for" loops, which provide a convenient means of looping over some or all of the records in an input window, or all of the data in a vector or dictionary.
for (record in input_window) {
...
}
The variable record is a new variable; you can use any name here. The scope
is the statement or block of statements in the loop; it has no meaning outside the loop. You
can also set equality criteria in searching for records with certain values of fields. For
example:
for (record in input_window where c=10, d=11) {
...
}
This statement has the same looping behavior, except limited to the records whose
c field is 10 and d field is 11. If you search on the key
fields, the loop runs at most one time, but it will run extremely fast because it will use the
underlying index of the stream.
for (val in vec1) {
...
}
The loop stops when the end of the vector is reached,
or the value of the vector is null.
for (key in dict1) {
...
}
It is common,
inside the loop,
to use the expression dict1[key]
to get the value held in the
dictionary for that particular key.