for
Iterate over a collection of statements
Syntax
for <index var name> = <lower bound>, <upper bound>, <optional step>
<list of equations/statements>
end
Description
The FOR statement is used to iterate over a collection of equations/statements. Most commonly, a FOR loop iterates over a range of integer values, but it can also iterate over a range of floating point values spaced over a prescribed interval. FOR loops are frequently associated with array variables/constants, where the loop is used to access individual elements in the array.
FOR loops may be nested, but care should be taken to not use the same index variable for multiple FOR loops. For purposes of sorting, the input and output quantities of a for loop are determined by the collection of statements inside the loop; however, statements inside the loop are not sorted. Rather, the entire FOR loop is sorted as a single statement. If the default sorting of the loop does not yield the intended model behavior, the loop can be enclosed in a PROCEDURAL section to force the intended sorting.
Note that labelled statements are now longer supported in the version of CSL used by Magnolia. The end of a loop is now delimited with a simple END statement.
Example
for i = 1, 100
x[i] = sin(k[i]*t)
end