for

for — checks a condition and performs a statement.

Syntax

for (setup ; condition ; iteration) statement

		

Arguments

setup

An iteration setup, usually a variable with an initial value.

condition

The condition to test.

iteration

Any Gamma expression, usually used to increment the variable in setup.

statement

Any Gamma statement.

Returns

The value of the condition.

Description

This statement is essentially identical to a for loop in C, and the syntax is the same. It checks a condition iteratively, and executes a statement when the condition is true.

Example

This for loop counts from 0 to 10, printing out the value of i as it loops.

for (i=0;i<=10;i++)
{
   princ("value of i: ", i, "\n");
}
		

See Also

Statements, while, with