Article View: comp.lang.postscript
Article #1998Re: PostScript coding style question
From: Charles B. Cranston
Date: Thu, 27 Aug 1992 21:26
Date: Thu, 27 Aug 1992 21:26
68 lines
2907 bytes
2907 bytes
In article <865@rtbrain.rightbrain.com>,
glenn@rightbrain.com (Glenn Reid) wrote:
> In a related (and silly) thread, I'm curious as to who has written the
> most deeply-nested "ifelse" or other statment in PostScript in a legitimate
> piece of PostScript code (e.g. not as an entry in the Most Obfuscated
> PostScript Contest). LaserPrep doesn't count :-)
Hi Glenn! Pity this doesn't work over a serial link because LF and
CR get mapped together by the silly input routine. The hack to make
it work (at the cost of losing overprinting by sending stuff CR stuff)
is left as an exercise for the student..
%!-Adobe-1.0
%%Title: asciiprint.ps
%%Creator: Ben Cranston <zben@umd2.umd.edu>
%%CreationDate: Thu Feb 8 1990
%%Pages 0
/Courier findfont 10 scalefont setfont
/colwid (m) stringwidth pop def
36 756 moveto
256 string
{ %exec
{ %loop over file
dup currentfile exch readstring exch
{ %loop FF
(\f) search exch
{ %loop LF
(\n) search exch
{ %loop CR
(\r) search exch
{ %loop TAB
(\t) search exch
{ %loop BS
(\b) search exch
show
not { exit } if
pop currentpoint exch colwid sub exch moveto
} loop %BS
not { exit } if
pop currentpoint exch 36 sub colwid div .49 add cvi
8 add dup 8 mod sub colwid mul 36 add exch moveto
} loop %TAB
not { exit } if
pop 36 currentpoint exch pop moveto
} loop %CR
not { exit } if
pop 36 currentpoint exch pop
11 sub dup 25 le { %if
pop showpage 756
} if
moveto
} loop %LF
not { exit } if
pop showpage 36 756 moveto
} loop %FF
not { exit } if
} loop %over file
pop showpage
} bind exec
The tab code has been changed to make it more readable and modifiable.
The two 8s are the tab stops, you should be able to change them to any
other number. The only other change is the indentation at three should
be a tad more readable than the old indentation at two.
zben@ni.umd.edu -KA3ZDF
Technical Details
Message-ID:
<zben-270892172239@zben-mac-ii.umd.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!haven.umd.edu!wam.umd.edu!ni.umd.edu!zben-mac-ii.umd.edu!userReferences:
<1992Aug21.160313@eklektix.com> <865@rtbrain.rightbrain.com>Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.postscript Path: arc1-ca.pugleaf.net!sparky!uunet!haven.umd.edu!wam.umd.edu!ni.umd.edu!zben-mac-ii.umd.edu!user From: zben@ni.umd.edu (Charles B. Cranston) Subject: Re: PostScript coding style question Message-ID: <zben-270892172239@zben-mac-ii.umd.edu> Followup-To: comp.lang.postscript Sender: usenet@ni.umd.edu (USENET News System) Nntp-Posting-Host: zben-mac-ii.umd.edu Organization: UM Home for the Terminally Analytical References: <1992Aug21.160313@eklektix.com> <865@rtbrain.rightbrain.com> Date: Thu, 27 Aug 1992 21:26:28 GMT Lines: 68