FOR
The FOR statement repeats a block of instructions a fixed number of times. The number of times that the script part is executed depends on the FROM and UPTO formulas. When reaching the FOR FROM UPTO statement, KCM calculates arguments and truncates the values to an integer value. KCM executes the script part and with every pass 1 is added to the FROM value until the UPTO value is reached.
The following is a definition of the statement.
FOR loop_counter
FROM formula
UPTO formula
DO
<Template scripting part with declarations>
OD
The loop counter is a NUMBER variable that must be declared before the FOR statement. The loop counter can be used in the DO...OD statement. Any changes to this variable are discarded at the end of the DO...OD part and do not affect the number of loops.
#BEGIN
NUMBER counter
FOR counter
FROM 2
UPTO 6
DO
#
The counter is @(number(counter; 0)).
#
OD
END#
Result:
The counter is 2.
The counter is 3.
The counter is 4.
The counter is 5.
The counter is 6.