Iterative Statements

Templex supports three types of iterative statements.

Each iterative loop begins with one of these statements and ends with the endloop statement.
while
The while iterative loop tests an exit condition before each execution of the iterative block. If the result is true (not zero), the statements inside the iterative block are executed. If the result is false (zero), the statement following the endloop statement is executed.
foreach
The foreach iterative loop consists of a foreach statement, a list of instructions, and an endloop statement. The instructions between foreach and endloop are carried out for each element in the array or list assigned in the foreach statement.
for
The for iterative loop consists of three parts: a for statement, Templex instructions, and the endloop statement. An initial value is specified for the counter in the for statement, as well as the exit condition and an operation to be performed on the counter each time a loop is completed. If the exit condition evaluates to false (zero), the statement following the endloop statement is executed. If the exit condition evaluates to true (not zero), the for iterative block Templex instructions are executed.