Looping Structures 110 TYPE " ", /C1 111 END 112 . A FOR loop can be made to count backward by entering a negative value for the step increment. 13 . 14 ; Count backward from 10 to 1 15 16 FOR i = 10 TO 1 STEP -1 17 TYPE i 18 END 19 . Changing the value of index inside a FOR loop will cause the loop to behave improperly. To avoid problems with the index , make the index variable an auto variable and do not change the index from inside the FOR loop. Changes to the starting and ending variables do not affect the FOR loop once it is executing. DO...UNTIL DO...UNTIL is a looping structure that executes a given block of code an indeterminate number of times.
Termination of the loop occurs when the Boolean expression or variable that controls the loop becomes true. The Boolean is tested after each execution of the code block-if the expression evaluates to true, the loop is not executed again. Since the expression is not evaluated until after the code block has been executed, the code block will always execute at least once. The form for this looping structure is: DO . code block . UNTIL expression expression is any well-formed Boolean expression. This expression must eventually evaluate to true, or the loop executes indefinitely. 20 . 21 ; Output the numbers 1 to 100 to the screen 22 23 x = 1 24 DO 25 TYPE x 26 x = x + 1 27 UNTIL x > 100 28 .
Step 26 ensures that x will reach a high enough value so that the expression x > 100 becomes true. 43 . 44 ; Echo up to 15 characters to the screen. Stop when 15 45 ; characters or the character "#" have been entered. eV+Language User's Guide, v2.x, 18318-000 Rev A Page 73