Sorry I didn't include this in my previous reply.
> From: Calum Galleitch <[EMAIL PROTECTED]>
> Date: Sat, 21 Jun 2003 22:02:38 +0000
> Ewan MacPherson has been kind enough to show me the code he uses for
> 1st and 2nd time phrases within parts/lines, and I've taken the
> liberty of reproducing part of it. My postscript skills are
> insufficiently l33t to understand what's going on in there with the
> line of exchs (if someone could explain it, I'd be very grateful),
> though I assume it has to do with the internal workings of abcm2ps:
Actually, exch is a postscript command that swaps the last two items on
the stack. As you probably know, postscript is a postfix language,
i.e., you put items on the stack, and then you perform an operation on
the top n items on the stack. Here's a simple example. The "sub"
command means subtraction, i.e., subtract the top item on the stack from
the next item on the stack.
postscript code result contents of stack (bottom to top)
---------------------- ------------- ---------------------------------
2 1 {2,1}
sub 1 {1}
2 1 {2,1}
exch {1,2}
sub -1 {-1}
> % -- draw "first time" indication
> %%postscript /firsttime { % usage: len x y firsttime
> %%postscript exch -9 add exch 2 copy
Presumably you've loaded the stack before calling the function
"firsttime". It looks like "firsttime" takes three arguments. The the
function is called with the items {len,x,y} preloaded onto the stack.
(Postscript uses a LIFO stack, so len is on the bottom of the stack and
y is on top.)
The first exch swaps the last two items, so the stack now contains
{len,y,x}. As I'm sure you realize, the -9 add command adds -9 to the
last item on the stack.. The stack then contains {len,y,x-9}. You exch
again to put the stack back in order. The stack now contains
{len,x-9,y}.
The copy command takes one argument, which is the number of items on the
stack to duplicate. In this case, the stack starts out with
{len,x-9,y}. "2 copy" would copy the last two items on the stack and
place those on the stack, resulting in the stack containing
{len,x-9,y,x-9,y}.
I hope this helps.
Jeff
To subscribe/unsubscribe, point your browser to: http://www.tullochgorm.com/lists.html