The repeat times instruction is used to execute a set of instructions a certain number of times.
Table 20.15. repeat times syntax
| Production | Syntax | Links |
|---|---|---|
repeat_times_instruction |
remark: | the section called “repeat times instruction” |
repeat_tail | ( "counter" ":" constant_id ) ? ( "id" ":" identifier ) ? | the section called “repeat tail” |
Example 20.17. repeat times example 1
// display numbers from 1 to 10 repeat 10 times counter: i system.console.write_line ( i.to_string ) end
Example 20.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_system.console.write_line ( "This is round " & c_repeat_counter.co_to_string )
if c_repeat_counter =v c_number_of_repeats then
se_system.console.write_line ( "This is the last round." )
end if
end repeat
end script
end command
end service