Shiny Language Reference
Language Reference > Basic Language
for
for(expression1;
expression2; expression3)
{
// Code segment
}
Executes code while an expression evaluates to TRUE
The FOR statement continuously loops through the code segment until the exit expression evaluates to TRUE.
Parameters
expression1
This is usually an expression that initializes a variable before beginning the loop. The variable is traditionally used as a counter.
expression2
This is an exit expression that evaluates to a boolean. The FOR loop continues to execute while this expression evaluates to TRUE, and exits when the expression evaluates to FALSE.
expression3
This expression is evaluated at the end of each loop iteration. Traditionally this is used to increment the counter variable initialized in expression1.
Return Value
No return value, this is a statement.
Example Code
for(int iCounter = 0; iCounter <= 10; iCounter++)
{
// Will display the numbers from 0 to 10 inclusive
print iCounter;
}