Cold Help System: Programming: ColdC Reference Manual: Language Structure: Statements: Looping Statements: for-range


The for-range statement is used to traverse a range of integers. The range is specified by seperating the lower and upper bounds of the range with the range operator (..), contained within the left and right square brackets ([ and ]). A for-list statement of this nature would look like:

for variable in [lower .. upper]
statement

lower and upper must be expressions resulting in an integer type (unlike a range in a switch). The interpreter executes statement once for each number from lower to upper, with variable being assigned the current number in the range. An example of using a range in a list is:

for i in [1 .. 10]
    .tell("iteration " + i);

Assigning to variable within a for-list statement will not change the status of the loop; the interpreter remembers where it is at in what and will continue as normal.


for-list | for-range | while | break | continue


the Cold Dark