Statement separators
Statements are separated by a semicolon (;).
Compound statements
One or more statements can be enclosed in curly braces to form a compound statement. Compound statements are commonly called “blocks” (not to be confused with FlexiLayout blocks).Conditional statements
In any section intended for entering code, you can use conditionalif statements.
The if statement controls conditional branching. The body of an if statement is executed if the value of the expression is true. The syntax for the if statement has two forms:
if statement, the expressions are evaluated.
In the first form of the syntax, if expression is true, statement is executed. If expression is false, statement is ignored. In the second form of the syntax, which uses else, the second statement is executed if expression is false.
Iteration statements
In any section intended for entering code, you can use iterationfor statements.
The for statement controls loops. The loop is executed while the value of the expression is true. The syntax has one form:
<var-name> counter name is required. This name must be different from the names of variables declared earlier. The scope of the counter is the body of the loop. Within the loop, you cannot change the counter value or declare a variable with the same name as the counter.
The initial <from-expr> and final <to-expr> counter values are evaluated before the first iteration of the loop. Then they are treated as integer constants to avoid endless loops.
The step parameter is optional. If the step value is not specified, the step is considered 1. The step value, along with the initial and final counter values, is evaluated once at the beginning of the loop.
The sign of the step determines the iteration condition:
- For positive step values, the condition
<var-name> ≤ <to-expr>must be met. - For negative step values, the condition
<var-name> ≥ <to-expr>must be met.
<statement> can be a single statement or a block (compound statement) enclosed in curly braces.
You can also use the following statements inside the loop:
break– Breaks the loop.continue– Goes to the next iteration of the loop.
