HOME


THE PRINCIPLE OF THE POSTSCRIPT PROGRAM PROCESS
EXPRESSED THROUGH A STORY ABOUT TO SMALL WORKMEN AND A STACK.

It is very detailed story and it has a rhythm so that it hopefully works up an understanding of whats happening along the way. At least this is the way I can work up an understanding of whats is happening.

THE STORY ABOUT TO SMALL WORKMEN AND A STACK

First let me introduce you to the Stackman. He runs along the lines of your program from left to right from top to bottom. In front of the Stackman runs an other little man. The Operator he is running backwards. In between the to small men is the Stack. The Stack is put on top of a little wagon so it can roll with the to small men. The Stackman is pushing it and the Operator is pulling it. The Stackman is looking for elements and values. The Operator is looking for operation instructions. The Stackman stacks every element and value he finds on to the Stack. The Operator pulls out things form the stack do the desired operation and puts the result back on top of the Stack.
Now lets follow them in there work:
The to small man and there stack arrives at this line:

(some text string ) centre

The Stackman puts the 'some text string' on top of the Stack

The Stack:

some text string

Next thing is 'center' an earlier defined routine
Both of the two small men have memoriesed this routine earlier in the program. They now that it is.

dup stringwidth pop 2 div rm lm sub 2 div exch sub lm add tm moveto show

First thing is 'dub' an Operator task.
The Operator pulls out 'some text string' from the top of the Stack. Duplicate it and puts the two results back in to the Stack on top of each other

The Stack:

some text string
some text string

Program process:
stringwidth pop 2 div rm lm sub 2 div exch sub lm add tm moveto show

Next thing is 'stringwidth' an Operator task
The Operator pulls out 'some test string' from the top of the Stack. Measure it. The result is the x and y coordinates fore the endpoint of the string. So the x coordinate which is 350 is put back on top oaf the Stack and the y coordinate which is 500 is put back in to the stack on top of the x coordinate.

The Stack:

500
350
some text string



Program process:
pop 2 div rm lm sub 2 div exch sub lm add tm moveto show

Next thing is 'pop' an Operator task
The Operator pulls out '500' from the top of the Stack and troughs it away
The Stack:

350
some text string


Program process:
2 div rm lm sub 2 div exch sub lm add tm moveto show

Next thing is '2' a Stackman task
The Stackman pickup 2 and puts it on top of the stack

The Stack:

2
350
some text string


Program process:
div rm lm sub 2 div exch sub lm add tm moveto show

Next thing is 'div' an Operator task
The Operator pulls out '2' from the top of the and puts it to a side. He pulls out what has now become the top of the Stack '350' and puts it on top of '2' to do the calculation:

Divide
350
2
----------
= 175



The result is left back on top of the Stack

The Stack:

175
some text string

Program process:
rm lm sub 2 div exch sub lm add tm moveto show

Next things is 'rm' and 'lm' two Stackman tasks
The Stackman pickup 'rm' which is an earlier memoresed definition containing the value 400 and puts it on top of the stack. He pickup 'lm' which is an earlier memoriesed definition containing the value 0 and puts it on top of the stack.

The Stack:

0
400
175
some text string

Program process:
sub 2 div exch sub lm add tm moveto show

Next thing is 'sub' an Operator task
The Operator pulls out '0' from the top of the and puts it to a side. He pulls out what has now become the top of the Stack '400' and puts it on top of '0' to do the calculation:

Subtract
400
0
----------
= 400

The result is left back on top of the Stack

The Stack:

400
175
some text string

Program process:
2 div exch sub lm add tm moveto show

Next thing is '2' a Stackman task
The Stackman pickup 2 and puts it on top of the stack

The Stack:

2
400
175
some text string

Program process:
div exch sub lm add tm moveto show

Next thing is 'div' an Operator task
The Operator pulls out '2' from the top of the and puts it to a side. He pulls out what has now become the top of the Stack '400' and puts it on top of '2' to do the calculation:

Divide
400
2
----------
= 200


The result is left back on top of the Stack

The Stack:

200
175
some text string

Program process:
exch sub lm add tm moveto show

Next thing is 'exch' an Operator task
The Operator pulls out '200' from the top of the and puts it to a side. He pulls out what has now become the top of the Stack '175' and puts it on top of '200' now he exchange the to and put first '200' back on top of the Stack and next '175' on top of it.

The Stack:

175
200
some text string

Program process:
sub lm add tm moveto show

Next thing is 'sub' an Operator task
The Operator pulls out '175' from the top of the and puts it to a side. He pulls out what has now become the top of the Stack '200' and puts it on top of '175' to do the calculation:

Subtract
200
175
----------
= 25

The result is left back on top of the Stack

The Stack:

25
some text string

Program process:
lm add tm moveto show

Next thing is 'lm' a Stackman task
The Stackman pickup 'lm' which, as we now know, is an earlier memoriesed definition containing the value '0' and puts it on top of the stack.

The Stack:

0
25
some text string

Program process:
add tm moveto show

Next thing is 'add' an Operator task
The Operator pulls out '0' from the top of the and puts it to a side. He pulls out what has now become the top of the Stack '25' and puts it on top of '0' to do the calculation:

Add
25
0
----------
= 25


The result is left back on top of the Stack

The Stack:

25
some text string

Program process:
tm moveto show

Next thing is 'tm' a Stackman task
The Stackman pickup 'tm' which is an earlier memoriesed definition containing the value '500' and puts it on top of the stack.

The Stack:

500
25
some text string

Program process:
moveto show

Next thing is 'moveto' an Operator task
The Operator pulls out '25' from the top of the Stack and sets that as x coordinate. He pulls out what has now become the top of the Stack '500' and sets that as y coordinate for the moveto action (placing the lower left corner of the string on the paper).
The Stack:

some text string

Program process:
show

Next thing is 'show' an Operator task
The Operator pulls out 'some text string' from the top of the Stack and prints it on the paper.

End of story.

/Mikkel


site map

'