PostScript arrays are one-dimensional collections of objects. These objects are numbered from zero, so that a ten-item array is numbered from zero to nine. POSTSCRIPT arrays are different from those in other languages in that their elements need not all be of the same type. That is, a single array may contain, for example, strings, integers, dictionaries, and other arrays. An array in a program is denoted by any collection of PostScript objects surrounded by square brackets. Thus, the lines
[16 (twelve) 8]
[(sum) 6 14 add]
both set up arrays. The first has three members: two numbers and a string. The second array has two items in it: the string sum and the number 20. (Note that operators within an array definition are carried out as the array is being defined.) Arrays may also be defined by the array operator. This operator takes a number from the stack and constructs an array of that length. The line
10 array
would leave a ten-place array on the stack. The elements of this array are initially all POSTSCRIPT null objects.
Leave a Reply
You must be logged in to post a comment.
Recent Comments