Loop

Syntax

LOOP [ WHILE ( expression ) ]
  <logic_block>
END | ENDEXIT | ENDNOPRINT

Parameters

The Loop logic command is followed by a set of logic statements to execute for each iteration, and finally by an End, EndNoPrint, or EndExit logic statement.

Description

The Loop logic command specifies a sequence of logic that is to be executed repeatedly. Loops can be nested within loops.

If the While command option is not specified, a condition should be included within the sequence of logic to specify the terminating conditions for the loop. Use Break and JumpTo logic statements, associated with DoWhen logic statements, to specify terminating conditions for the loop within the sequence of logic. Use Continue to skip processing the remainder of the logic in the loop for the current iteration.

If the EndExit logic command is used to terminate the sequence of logic, and it is executed, the loop is not repeated, and the current class exits as with a normal EndExit logic statement.

Examples

Example 1

LoopIterator := 0 
Loop While (LoopIterator < ArraySize) 
      : logic statements 
     LoopIterator = LoopIterator + 1 
End

Example 2

In this example, if SortQues is a string attribute set to "ZYXWVUTSRQPOMNLKJIHGFEDCBA", the result in SortAns, of length larger than 25, is "ABCDEFGHIJKLMNOPQRSTUVWXYZ".

Loop 
       Counter = Counter + 1 
       Move SortQues POS Counter Length 1 SortAns SortA 
       If (Counter > 25) 
              Break 
       End 
End

Example 3

This example, in a report, prints Frame06 when a valid product name is input. The loop is used to repeat the prompt for input if an invalid product name is supplied.

Loop   
     Message Attention "Enter Product Name" 
     Accept ProdName 
     LookUp ProdName Prod 
     If Glb.Status <> "*****" 
           Break 
     End 
     Message ProdNam "Product name not valid" 
End 
Frame06.Print()