The repeat from to instruction is used to execute a set of instructions over a range of integer values stored in a loop variable. The loop variable starts and ends with specified values. At each pass, it is incremented or decremented by one, or any other specified step value. The loop variable can be accessed by instructions within the loop.
![]() | Note |
|---|---|
The repeat from to instruction is similar to the frequently used for (int i=0; i<max; i++) statement in Java and C#. |
Table 8.14. repeat from to syntax
| Production | Syntax | Links |
|---|---|---|
repeat_from_to_instruction |
remarks:
| the section called “repeat from to instruction” |
repeat_tail | ( "counter" ":" variable_id ) ? ( "id" ":" identifier ) ? | the section called “repeat tail” |
Example 8.14. repeat from to example 1
// display numbers from 1 to 10 repeat from i = 1 to 10 console.message ( i.to_string ) end
Example 8.15. repeat from to example 2
// display even numbers between 10 and 4 repeat from i = 10 down to 4 step 2 console.message ( i.to_string ) end
The result on screen is:
10 8 6 4
Example 8.16. repeat from to example 3
service instruction_examples
command repeat_from_to_example_2
script
// create table data provider with 2 rows and 4 columns, and containing some simple test data
const positive32 row_count = 2
const positive32 column_count = 4
const table_data_provider table_data_provider = fa_table_data_provider_for_tests.co_create ( &
i_row_count = c_row_count &
i_column_count = c_column_count )
// loop through all rows
repeat from row_index = 1 to c_row_count
// loop through all even columns
repeat from column_index = 2 to c_column_count step 2
// display cell value
se_console.co_message ( c_table_data_provider.co_cell_value ( &
i_row_index = v_row_index &
i_column_index = v_column_index ).to_string )
end repeat
end repeat
end script
end command
end serviceThe result on screen is:
r1 c2 r1 c4 r2 c2 r2 c4