The repeat times instruction is used to execute a set of instructions a certain number of times.
Table 8.15. repeat times syntax
| Production | Syntax | Links |
|---|---|---|
repeat_times_instruction |
remark: | the section called “repeat times instruction” |
repeat_tail | ( "counter" ":" variable_id ) ? ( "id" ":" identifier ) ? | the section called “repeat tail” |
Example 8.17. repeat times example 1
// display numbers from 1 to 10 repeat 10 times counter: i console.message ( i.to_string ) end
Example 8.18. repeat times example 2
The code below will display the following on the system console:
This is round 1 This is round 2 This is round 3 This is the last round.
service instruction_examples
command repeat_times_example_2
script
const positive32 number_of_repeats = 3
repeat c_number_of_repeats times counter: repeat_counter
se_console.co_message ( "This is round " & v_repeat_counter.co_to_string )
if v_repeat_counter =v c_number_of_repeats then
se_console.co_message ( "This is the last round." )
end if
end repeat
end script
end command
end service