for

Gamma: Version 4.0
Prev |  | Next

# `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 the Starting qserve and nserve section of the Common Functions chapter in the Cogent Tools Demo and Tutorials book for an example of this statement used in context.

## See Also

Statements, `while`, `with`

Prev | Home | Next
`condition` | Up | `function`

Copyright 1995-2002 by Cogent Real-Time Systems, Inc.