Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Reid G.C.Thinking in PostScript.1990.pdf
Скачиваний:
17
Добавлен:
23.08.2013
Размер:
846.44 Кб
Скачать

Chapter 8

Using Looping Constructs

Loops are useful for repeating a sequence of steps in a quantized manner. There are various conditions under which looping is appropriate. One of the most common is to iterate over data structures of known size, such as arrays. Another use is to repeat a set of commands more than once.

If you want to perform a repetitive task that uses some fixed parameters, you generally think of loops in most programming languages. For example, you could create a grid of lines or a spiral of text by setting up a for loop and using the loop increment to set up the next line or the next rotation of characters.

One fairly common use of loops is to generate “synthetic” graphics. The data for a grid of lines or a spiral actually can be manufactured within the loop rather than being supplied as a large body of individual x, y coordinates and sequences of moveto and lineto instructions. However, using one of the loop operators can be an extremely useful technique even with real data that are not synthetically generated within the loop itself (as

93