Skip to content

Loops

Loops in CES allow code to be executed repeatedly while a condition is true or for a specific number of iterations.

They are useful for automating repetitive tasks, processing data, and controlling execution flow.

While loop

The while loop executes a block of code as long as the condition remains true.

Example:

Int count: 0;

while(count < 5)
{
    DisplayLog(count);
    count = count + 1;
}

Expected output

0
1
2
3
4

For loop

The for loop executes a block of code for a fixed number of iterations.

Example:

for(Int i: 0; i < 5; i = i + 1)
{
    DisplayLog(i);
}

Expected output

0
1
2
3
4