Chapters:
1: Introduction
2: Simple example
3: Invocation
4: Finer Control
5: X-Y Plots
6: Contour Plots
7: Image Plots
8: Examples
9: Gri Commands
10: Programming
11: Environment
12: Emacs Mode
13: History
14: Installation
15: Gri Bugs
16: Test Suite
17: Gri in Press
18: Acknowledgments
19: License
Indices:
Concepts
Commands
Variables

### 9.3.52: ``while`'

    `while .test.|{rpn ...}'

Perform statements in loop while the value of ``.test.`' or the RPN expression is nonzero. The end of the loop designated by a line containing the words ``end while`'. The value ``.test.`' may be an rpn expression. To leave the loop prematurely, use a ``break`' statement. Upon encountering a ``break`' statement, Gri jumps to the line immediately following the loop. If the ``-chatty`' option is nonzero, a notification is printed every 1000 passes through the loop, as a debugging measure to catch unintended infinite loops.

Examples:

- Loop forever, printing a message over and over.

      while 1
        show "This loops forever. Need to 'break'"
      end while

- Repeatedly read two numbers, and plot a bullet at the indicated location. If (or, hopefully, ``when'') the end of the file is encountered, break out of the loop; otherwise continue plotting forever.

      while 1
        read .x. .y.
        if ..eof..
          break
        end if
        draw symbol bullet at .x. .y.
      end while

- Loop 10 times, printing the values of ``.i.`' as they range 0, 1, ..., 9. After exiting from the loop, ``.i.`' will equal 10. Be careful to use the correct rpn greater-than test to avoid an infinite loop.

      .i. = 0
      while {rpn .i. 10 >}
        show .i.
        .i. += 1
      end while