For Loops

Use for loops to iterate once over the records in a window, or the data in a vector or dictionary. To iterate multiple times over the records, use a window iterator. They ensure that the data is consistent while they are in use.

To loop over every record in an input window named input1:
for (record in input1_stream) {
  ...
}
          
The variable record is a new variable; you can use any name here. The input1_stream variable is automatically created to get the data from the window into the for loop. 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 input1_stream where c=10, d=11) {
  ...
}
          
This statement has the same looping behavior, except limited to those records with a value of 10 in the c field and a value of 11 in the d field. 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.
To loop over the values in a vector named vec1, where val is any new variable:
for (val in vec1) {
 ...
}
          
The loop stops when the end of the vector is reached, or the value of the vector is null.
To loop over the values in a dictionary name dict1, where key is any new variable:
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.