next up previous contents index
Next: Other remarks Up: Commands controlling program flow Previous: Other remarks

Looping until a condition is satisfied

   


tex2html_wrap_inline33790 tex2html_wrap_inline33790 Syntax

BD>repeat : tex2html_wrap_inline33712

BD>... tex2html_wrap_inline33712

BD>...Body of commands tex2html_wrap_inline33712

BD>... tex2html_wrap_inline33712

BD>until : E tex2html_wrap_inline33712

where E is any valid equation.

tex2html_wrap_inline33806 tex2html_wrap_inline33806

The REPEAT:  ...UNTIL:  construction is used to provide a loop surrounding a body of commands which will be processed at least once, and will continue to be processed the equation E becomes TRUE. The equation is defined to be TRUE if the rounded value of the equation is equal to unity, and FALSE otherwise. If no equation is given, or if a mistake is made in determining the equation, then [B/D] assumes that a valid equation with value TRUE has been supplied, and the loop will not be repeated.

Both the initiating REPEAT:  and the terminating UNTIL:  command must be given on a separate line, and you should be careful not to confuse separate repeat ...until structures where you are nesting them.

As an example, consider the following program fragment.

BD>c : %i=0 tex2html_wrap_inline33712

BD>repeat : tex2html_wrap_inline33712

BD>c : %i=%i+1 tex2html_wrap_inline33712

BD>c : %j=0 tex2html_wrap_inline33712

BD>repeat : tex2html_wrap_inline33712

BD>c : %j=%j+1 tex2html_wrap_inline33712

BD>print : (%i), (%j) tex2html_wrap_inline33712

BD>until : %j=2 tex2html_wrap_inline33712

BD>until : %i=2 tex2html_wrap_inline33712

This code establishes two loops during which the constants take the values (%i=1,%j=1), (%i=1,%j=2), (%i=2,%j=1), (%i=2,%j=2), and then terminate.





David Wooff
Wed Oct 21 15:14:31 BST 1998