Table of Contents
Commands for manipulating the operand stack in PostScript.
1. Overview
The operand stack is fundamental to PostScript execution. These operators provide essential capabilities for managing stack contents, including duplicating, exchanging, copying, and removing elements.
2. Stack Manipulation Commands
| Command | Description |
|---|---|
Remove the top element from the stack |
|
Exchange the top two stack elements |
|
Duplicate the top element |
|
Copy top n elements or duplicate composite object values |
|
Duplicate the nth element from the top |
|
Roll n elements j times |
|
Count elements on the stack |
|
Remove all elements from the stack |
|
Push a mark object onto the stack |
|
Pop elements down to and including a mark |
|
Count elements down to a mark |
3. Common Patterns
Stack manipulation operators are often used in combination:
% Duplicate and swap
5 dup exch % Create two copies and swap positions
% Copy multiple elements
1 2 3 3 copy % Duplicate top 3 elements
% Access deep element
a b c d 3 index % Copy element 3 positions down
4. See Also
-
Command Reference - All PostScript commands