do  Jump statements

Chapter 1: Overview

for

The for statement starts by initializing the variables used in the conditional expression, testing the conditional expression, then executing the loop’s statements if the condition is true (non-zero). It then increments the variables used in the conditional expression, tests the conditional expression, then executes the loop’s statements if the condition is true (non-zero). It continues in this pattern until the value of the conditional expression is false (zero).

Currently, you must include all three expressions in a for loop.

for (init; condition; loop) init = initial condition
{	condition = conditional expression
	do these commands; loop = loop expression
}

NoteBecause ODL, unlike C, does not allow null statements, you must have an expression for each of the three components within the parentheses. You cannot, for example, have a for loop expression statement such as:

for (; i<5 ; i++)

Also, you must list at least one command to perform within the loop (in addition to the loop expression). You cannot, for example, put this:

for (i=0; i<10; i++);

Since there is no command preceding the semicolon, that would be a null (command) statement as well.





Copyright © 2005. Sybase Inc. All rights reserved. Jump statements

View this book as PDF