PostScript Stack Commands

5.5.2 PostScript Stack Commands


[=] [count] [clear] [copy] [dup] [exch] [index] [pop] [stack] [roll]

=

object = -

This command removes the topmost object from the stack and prints it.


count

count depth of stack

This operator puts the depth of the stack on the top of the stack.


clear

bottom of stack top of stack clear -

This operator removes all objects from the stack.


copy

obn ... ob1 n copy obn ... ob1 obn ... ob1 This operator adds a copy of the top n objects on the stack.

dup

ob1 dup ob1 ob1

This operator adds a duplicate copy of the top object of the stack to the stack.


exch

ob1 ob2 exch ob2 ob1

This operator exchanges the position of the top two elements on the stack.


index

obn ... ob1 n index obn ... ob1 obn

This operator adds a copy of the nth object in the stack to the top.


pop

ob1 pop -

This operator exchanges the position of the top two elements on the stack.


stack

- dup -

This command prints a copy of the entire stack, starting from the top and working to the bottom.


roll

object n-1 ... ob 0 n jroll object n-1 mod j ... ob 0 mod j This operator permutes the top n objects on the stack as described in the example .

David Maxwell, who is still writing this, would like to hear your comments and suggestions. And remember, parts of this manual are based on P.J. Weingartner's work: A First Guide to PostScript.