For in AngelScript

**for** is Angelscript's looping construct. Here are some basic types of **for** loops.

The most basic type, with a single condition.

```angelscript
void main() {
    int i = 1;
    while (i <= 3) {
        print("" + i + "\n");
        i = i + 1;
    }
}

A classic initial/condition/after for loop.

void main() {
    for (int j = 0; j < 3; j++) {
        print("" + j + "\n");
    }
}

Another way of accomplishing the basic “do this N times” iteration is for with a range-like loop.

void main() {
    for (int i = 0; i < 3; i++) {
        print("range " + i + "\n");
    }
}

for without a condition will loop repeatedly until you break out of the loop.

void main() {
    while (true) {
        print("loop\n");
        break;
    }
}

You can also continue to the next iteration of the loop.

void main() {
    for (int n = 0; n < 6; n++) {
        if (n % 2 == 0) {
            continue;
        }
        print("" + n + "\n");
    }
}
$ angelscript run for.as
1
2
3
0
1
2
range 0
range 1
range 2
loop
1
3
5

We’ll see some other for forms later when we look at range statements and other data structures.