🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: adobe.postscript.programming
3 messages
3 total messages Started by Attila_Kirjak Wed, 18 Aug 2004 21:08
Can someone check the code snippet included?
#345
Author: Attila_Kirjak
Date: Wed, 18 Aug 2004 21:08
13 lines
945 bytes
Could anyone confirm if this code snippet is working properly or multiple calls of MoveRight might cause a stack overflow?

%%
/MoveRight {
stringwidth pop
neg 0 rmoveto } def
%%
171 395 moveto
gsave
(Some Text Comes Here) MoveRight
(Some Text Comes Here) show
grestore
%%
Re: Can someone check the code snippet included?
#346
Author: Odysseus
Date: Wed, 18 Aug 2004 23:51
38 lines
1908 bytes
In article <3bb589d0.-1@webx.la2eafNXanI>,
 Attila_Kirjak@adobeforums.com wrote:

> Could anyone confirm if this code snippet is working properly or multiple 
> calls of MoveRight might cause a stack overflow?
> 
> %%
> /MoveRight {
> stringwidth pop
> neg 0 rmoveto } def
> %%
> 171 395 moveto
> gsave
> (Some Text Comes Here) MoveRight
> (Some Text Comes Here) show
> grestore
> %%

The procedure doesn't leave anything on the stack, but it's not very 
efficient having to supply the text twice; the "gsave" and "grestore" 
operators are also unnecessary (unless you'll also be temporarily 
changing fonts, colours, co�rdinates, &c. in the code that falls between 
them). Instead you might try something like

%!
/FlushRight {
   dup stringwidth pop
   neg 0 rmoveto show} def
% ...
171 395 moveto
(Some Text) FlushRight

Note that at the end of this sequence the current point will be at 
(171,395) again, because the "show" operator will set it there after 
painting the text.

-- 
Odysseus
Re: Can someone check the code snippet included?
#348
Author: tgreer
Date: Fri, 20 Aug 2004 19:38
3 lines
704 bytes
It's fine.

but just add "dup" before stringwidth to get rid of the two strings.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads