3.5.6 LoopsWith the LOOP, EXIT, CONTINUE, WHILE, and FOR statements, you can arrange for your SPL program to repeat a series of commands.184.108.40.206 LOOPLOOP defines an unconditional loop that is repeated indefinitely until terminated by an EXIT or RETURN statement.220.127.116.11 EXITEXIT [ WHEN expression ];The innermost loop is terminated and the statement following END LOOP is executed next.If WHEN is present, loop exit occurs only if the specified condition is true, otherwise control passes to the statement after EXIT.EXIT can be used to cause early exit from all types of loops; it is not limited to use with unconditional loops.The following is a simple example of a loop that iterates ten times and then uses the EXIT statement to terminate.18.104.22.168 CONTINUEThe CONTINUE statement provides a way to proceed with the next iteration of a loop while skipping intervening statements.When the CONTINUE statement is encountered, the next iteration of the innermost loop is begun, skipping all statements following the CONTINUE statement until the end of the loop. That is, control is passed back to the loop control expression, if any, and the body of the loop is re-evaluated.If the WHEN clause is used, then the next iteration of the loop is begun only if the specified expression in the WHEN clause evaluates to true. Otherwise, control is passed to the next statement following the CONTINUE statement.The CONTINUE statement may not be used outside of a loop.The following is a variation of the previous example that uses the CONTINUE statement to skip the display of the odd numbers.22.214.171.124 WHILEWHILE expression LOOPThe WHILE statement repeats a sequence of statements so long as the condition expression evaluates to TRUE. The condition is checked just before each entry to the loop body.The following example contains the same logic as in the previous example except the WHILE statement is used to take the place of the EXIT statement to determine when to exit the loop.Note: The conditional expression used to determine when to exit the loop must be altered. The EXIT statement terminates the loop when its conditional expression is true. The WHILE statement terminates (or never begins the loop) when its conditional expression is false.126.96.36.199 FOR (integer variant)FOR name IN [REVERSE] expression .. expression LOOPThis form of FOR creates a loop that iterates over a range of integer values. The variable name is automatically defined as type INTEGER and exists only inside the loop. The two expressions giving the loop range are evaluated once when entering the loop. The iteration step is +1 and name begins with the value of expression to the left of .. and terminates once name exceeds the value of expression to the right of ... Thus the two expressions take on the following roles: start-value .. end-value.The optional REVERSE clause specifies that the loop should iterate in reverse order. The first time through the loop, name is set to the value of the right-most expression; the loop terminates when the name is less than the left-most expression.The following example simplifies the WHILE loop example even further by using a FOR loop that iterates from 1 to 10.Here is the output using the FOR statement.If the start value is greater than the end value the loop body is not executed at all. No error is raised as shown by the following example.