Skip to main content

Separate statements

Statements are separated by ”;” (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 conditional if 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. Syntax selection-statement :
if ( expression ) then statement

if ( expression ) then statement else statement
In both forms of the 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 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 iteration for statements. The for statement controls loops. The loop is executed while the value of the expression is true. Syntax iteration statement :
for <var-name> from <from-expr> to <to-expr> [ step <step-expr>]

<statement>
The name of the <var-name> counter is compulsory. This name must be different from the names of variables declared above. The scope of the counter is the body of the loop. Changing the value of the counter or declaring variables with the same name as the counter is not allowed within the loop. The initial from-expr and final to-expr counter values are evaluated before the first iteration of the loop is performed. 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 as well as its initial and final values is evaluated once at the beginning of the loop. Depending on the sign of the step the condition for the iteration is chosen. For positive step values, the following condition must be met: <var-name> ≤ <to-expr>, for negative step values, the condition is as follows: <var-name> ≥ <to-expr>. The step value cannot be zero; otherwise, an error message will occur. The <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.