9.5 'for', 'FOR' loops

-----------------------

Syntax:

for ([<initial expression>]; [<condition>]; [<incrementation>])

<operator>

The loop 'for' is executed until the value <condition> is false. If

<condition> starts off false, then the body of 'for' is not executed and

control is immediately passed to the following statement. <initial

expression> and <incrementation> are usually used to initialize and modify

the loop options.

The first step in executing 'for' is to calculate <initial expression>

if one exists. Then <condition> is calculated and evaluated as follows:

If <condition> is true, then the body of the operator is executed,

after wheich <incrementation>, if it exists, is calculated, and the process

repeats.

If <condition> is omitted, then it is taken to have a value of true.

In this case 'for' is an endless loop which can end only if there is a

'break', 'goto', or 'return' in its body.

If <condition> is false, then the 'for' loop terminates and control

passes to the next statement.

'FOR' is similar to 'for' but the code generates is 3 bytes shorter. The

code generated in a 'FOR' loop must be less than 127 bytes.

Example:

for(i=0;i<5;i++){

WRITESTR("STRING");

WRITEWORD(i);

WRITELN();

}

There is no restriction on the size of <initial expression> and

<incrementation>. Statements in these must be comma-separated.

for ( a=1, b=2 ; a<5 ; a++, b+=a ) {...

Logical integration of <conditions> is also possible. Up to 32

conditions can be logically combined. Each of these conditions must be in

parentheses. For example:

for ( a=0 ; (a>=0) && (a<10) ; a++ ){...