The repeat while instruction is used to repeat executing a set of instructions as long as a certain condition is fulfilled.
Table 8.12. repeat while syntax
| Production | Syntax | Links |
|---|---|---|
repeat_while_instruction |
remark: | the section called “repeat while instruction” |
repeat_tail | ( "counter" ":" variable_id ) ? ( "id" ":" identifier ) ? | the section called “repeat tail” |
Example 8.9. repeat while example 1
// display numbers from 1 to 10 var positive32 i = 1 repeat while i <= 10 console.message ( i.to_string ) i = i + 1 end
Example 8.10. repeat while example 2
service instruction_examples
command repeat_while_example_2
script
// ask user to type a string composed of 3 characters
var string user_input // declare variable to hold result
var yes_no input_ok = no
repeat while not v_input_ok // loop while input is not ok
v_user_input = se_console.co_ask_string ( "Please enter 3 characters:" ) // ask user to enter a string on the system console
v_input_ok = v_user_input.a_item_count =v 3 // check if exactly 3 characters have been entered
if not v_input_ok then
se_console.co_message ( "Input error! Please try again!" ) // if not ok: display error message and restart again
end if
end repeat
se_console.co_message ( "You typed: " & user_input ) // display result
end script
end command
end service