repeat times instruction

Description

The repeat times instruction is used to execute a set of instructions a certain number of times.

Syntax

Table 8.15. repeat times syntax

ProductionSyntaxLinks
repeat_times_instruction

"repeat" expression "times" repeat_tail ?
   script_instruction *
"end" "repeat" ?

remark: expression must be of type positive32

the section called “repeat times instruction”
repeat_tail( "counter" ":" variable_id ) ? ( "id" ":" identifier ) ?the section called “repeat tail”

Examples

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

See also