🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.postscript.programming
Article #346

Re: Can someone check the code snippet included?

#346
From: 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
Technical Details
Message-ID: <odysseus1479-at-86C921.17513418082004@news.telus.net>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed2.telusplanet.net!newsfeed.telus.net!edtnps84.POSTED!53ab2750!not-for-mail
References: <3bb589d0.-1@webx.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10c61a,6baa3d20c1ca42ce
X-Google-Attributes: gid10c61a,public
X-Google-Language: ENGLISH,ASCII
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed2.telusplanet.net!newsfeed.telus.net!edtnps84.POSTED!53ab2750!not-for-mail
From: Odysseus <odysseus1479-at@yahoo-dot.ca>
Newsgroups: adobe.postscript.programming
Subject: Re: Can someone check the code snippet included?
References: <3bb589d0.-1@webx.la2eafNXanI>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
User-Agent: MT-NewsWatcher/3.4 (PPC Mac OS X)
Message-ID: <odysseus1479-at-86C921.17513418082004@news.telus.net>
Lines: 38
Date: Wed, 18 Aug 2004 23:51:34 GMT
NNTP-Posting-Host: 199.126.210.96
X-Trace: edtnps84 1092873094 199.126.210.96 (Wed, 18 Aug 2004 17:51:34 MDT)
NNTP-Posting-Date: Wed, 18 Aug 2004 17:51:34 MDT