Misc.ps
Copyright Ó 1987 by Xerox Corporation. All rights reserved.
Doug Wyatt, June 8, 1987 4:26:06 pm PDT
Starting an interpreter:
← &streams ← ViewerIO.CreateViewerStreams["PostScript"]
← PSLanguage1Impl.Create[&streams.in, &streams.out]
Undocumented primitives in systemdict:
clearinterrupt disableinterrupt enableinterrupt
packedarray currentpacking setpacking
currentcacheparams setcacheparams
cexec eexec setram setrom daytime internaldict makevm psdevice
Undocumented items in statusdict:
appletalktype blink closescc debugmode diablo eerom frametoprinter initappletalk jobsource jobstate openappletalk openscc printerclose printerstatus resetprinter sccfiles sendpcmd setappletalkname setblink setstdio switchsetting
Undocumented items in serverdict:
0 1 2 3 altflag altin altname altout altprint appletalkclose appletalkopen batchidleproc baud25 baud9 commhash dexch exchdef execjob exitserver fontname hashcommparams initprinter intidleproc parity25 parity9 printerstatus protect saveswitch sccok secretdict sendctrld server setnulldevice setrealdevice setsccstreams setstreams settimeouts specialswitch startpage stdin stdname stdout switchclose switchopen transparent warmedup watchstreams wtimeout
Exploring dictionaries:
systemdict { dup type /operatortype eq { pop pop } { exch ==print ==print (def\n) = } ifelse } forall
userdict { exch ==print ==print (def\n) = } forall
systemdict { type /operatortype eq { pop } { dup xcheck { = } { pop } ifelse } ifelse } forall
% VM consumption by dictionaries:
/vmused { vmstatus pop exch pop } def
/vm { vmused = } def
/dictvm {
0 begin
/max exch def
/vcur vmused def
/dcur 0 def
1 1 max {
dup dict pop
/vprev vcur def
/dprev dcur def
/vcur vmused def
/dcur vcur vprev sub def
dup =print (: ) print
dcur =print (, ) print dcur dprev sub =print
( [) print dcur exch div =print (]\n) print
} for
end
} dup 0 10 dict put def
% VM consumption by arrays:
/vmused { vmstatus pop exch pop } def
/arrayvm {
0 begin
/max exch def
/vcur vmused def
/dcur 0 def
1 1 max {
dup array pop
/vprev vcur def
/dprev dcur def
/vcur vmused def
/dcur vcur vprev sub def
dup =print (: ) print
dcur =print (, ) print dcur dprev sub =print
( [) print dcur exch div =print (]\n) print
} for
end
} dup 0 10 dict put def
% VM consumption by packedarrays:
% small integers [-1..18] take 1 byte
% reals 0.0, 1.0, -1.0 take 1 byte
% booleans take 1 byte
% strings of length [1..32] take 3 bytes
% names take 2 bytes
% operators take 2 bytes
% everything else takes 9 bytes
/vmused { vmstatus pop exch pop } def
/packedarrayvm {
0 begin
/ob exch def
/max exch def
/vprev 0 def
/dprev 0 def
/dcur 0 def
/n 0 def
/vcur vmused def
1 1 max {
/n exch def
n { /ob load } repeat n packedarray pop
/vprev vcur def
/dprev dcur def
/vcur vmused def
/dcur vcur vprev sub def
n =print (: ) print
dcur =print (, ) print dcur dprev sub =print
( [) print dcur n div =print (]\n) print
} for
end
} dup 0 10 dict put def
% serverdict contents:
/saveswitch 0 def
/intidleproc { /idleproc { } readonly def^ /print systemdict /print get^ def^ -dict- begin^ /watchstreams load^ UseIdleTime setrealdevice 0 defaulttimeouts^ pop^ exch^ pop^ 0 settimeouts protect end^ } readonly def
0 { clearinterrupt^ disableinterrupt^ -dict- begin^ /watchstreams load^ UseIdleTime setrealdevice -dict- begin^ /idleproc { /idleproc { } readonly def^ -dict- begin^ 0 defaulttimeouts^ pop^ exch^ pop^ 0 settimeouts end^ } readonly def^ end^ protect defaulttimeouts^ settimeouts enableinterrupt^ stdin end^ cvx^ exec^ disableinterrupt^ } readonly def
1 { clearinterrupt^ disableinterrupt^ -dict- begin^ /watchstreams load^ UseIdleTime setrealdevice -dict- begin^ /idleproc { /idleproc { } readonly def^ -dict- begin^ 0 defaulttimeouts^ pop^ exch^ pop^ 0 settimeouts end^ } readonly def^ end^ protect defaulttimeouts^ settimeouts enableinterrupt^ stdin end^ cvx^ exec^ disableinterrupt^ } readonly def
/setsccstreams { -dict- begin^ /parity25 exchdef /baud25 exchdef -dict- /debugmode get^ 0 ne^ { /baud25 0 def^ } readonly if^ /parity9 exchdef /baud9 exchdef baud9 baud25 or^ 0 eq^ { /baud9 1200 def^ /baud25 1200 def^ } readonly if^ /altflag baud9 0 ne^ baud25 0 ne^ and^ def^ /sendctrld true def^ /transparent saveswitch 2 eq^ 58 eescratch^ 0 eq^ and^ def^ commhash hashcommparams dup^ /commhash exchdef eq^ baud9 0 ne^ { 9 sccfiles^ status^ exch^ status^ and^ and^ } readonly if^ baud25 0 ne^ { 25 sccfiles^ status^ exch^ status^ and^ and^ } readonly if^ /sccok exchdef 25 baud25 0 ne^ { sccok { sccfiles^ } readonly { baud25 parity25 transparent openscc^ } readonly ifelse^ (serial 25) } readonly { closescc^ } readonly ifelse^ 9 baud9 0 ne^ { sccok { sccfiles^ } readonly { baud9 parity9 transparent openscc^ } readonly ifelse^ (serial 9) } readonly { closescc^ } readonly ifelse^ /stdname exchdef /stdout exchdef /stdin exchdef altflag { /altname exchdef /altout exchdef /altin exchdef } readonly if^ stdin stdout setstdio^ end^ } readonly def
/exitserver -array- def
/parity9 0 def
2 { 58 eescratch^ dup^ -dict- exch^ known^ { } readonly { pop^ 0 } readonly ifelse^ -dict- exch^ get^ exec^ } readonly def
/parity25 0 def
/protect -packedarray- def
/hashcommparams { switchsetting^ 9 sccbatch^ 25 sccbatch^ 9 sccinteractive^ 25 sccinteractive^ 58 eescratch^ 9 { 3 bitshift^ add^ } readonly repeat^ } readonly def
3 { clearinterrupt^ disableinterrupt^ -dict- begin^ /watchstreams load^ UseIdleTime setrealdevice -dict- begin^ /idleproc { /idleproc { } readonly def^ -dict- begin^ 0 defaulttimeouts^ pop^ exch^ pop^ 0 settimeouts end^ } readonly def^ end^ protect defaulttimeouts^ settimeouts enableinterrupt^ stdin end^ cvx^ exec^ disableinterrupt^ } readonly def
/startpage (userdict begin
/k{load def}def/d/def k/sh/show k/ff/findfont k/xc/exch k
/rd{round xc}d/rp/repeat k/dl{transform rd rd itransform}d
/r/roll k/b{4 copy m xc 3 -1 r l 4 2 r l l cp}d
/cp/closepath k/s/stroke k/f/fill k/m{dl moveto}d
/va{3 -1 r add xc 3 -1 r add xc}d
/rm{tp va dl moveto}d
/tp/currentpoint k/l{dl lineto}d/rl{tp va dl lineto}d
/c/curveto k/sl/setlinewidth k/sg/setgray k/t/translate k
/gs/gsave k/gr/grestore k/a/arc k/bf{b gs f gr 0 sg s}d
/sf{scalefont setfont}d/pg{1 sg 1 sl 0 0 132 160 bf}d
/pt{=string cvs sh}d/sw/stringwidth k/tr/Times-Roman ff d
/hv/Helvetica ff d/sy/Symbol ff d
/xln{dup 60 gt{ln}{pop 4.1} ifelse}d
/sp{xc cvx exec}d
/rs{dup 9 sp 24 lbx 26 16 m(9)sh 25 sp 44 lbx 45 16 m(25)sh}d
/lbx
{gs 24 t[.2 .6 .9 1]xc 4 mod get sg dup dup xln 4 sub 20 mul 10 xc
0 0 4 2 r bf gr
gs 4 24 t xln 4 sub 20 mul 0 xc m 0 -3 rm gs 0 sg pt( -)pt gr gr
}d
/tc{gs 14 24 t .5 sl xc{dup 0 t 0 0 m 0 3 rl s}rp pop gr}d
/pgs
{gs .5 sl
-4 0 rm tp -12 0 rl 0 13 rl 4 0 rl 0 4 rl 8 0 rl cp s
.7 sl m -12 13 rm 4 4 rl s gr}d
/mino {2 copy gt {xc}if}d
/aqy 8 array d /aqi 0 d /aqp {aqy xc aqi xc put /aqi aqi 1 add d}d
newpath clippath {xc aqp aqp}{xc aqp aqp}{}{}pathforall newpath
aqy 0 get aqy 4 get mino /xh xc d /xl xc d
aqy 1 get aqy 5 get mino /yh xc d /yl xc d
xl xh add 2 div 306 sub yl yh add 2 div 396 sub t
tr 12 sf
0 sl
36 36 576 756 b s
statusdict begin
=string printername dup sw pop -2 mul 306 add 650 m
gs tr 48 sf sh gr
134 294 m
sy 28 sf
gs(p)true charpath gs 0 sg 2 sl s gr gs 1 sg 1.2 sl s gr gr
tr 12 sf
pagecount =string cvs
306 72 m sh
306 72 m pgs
110 130 t
1 sl
0 92 342 156 b s
14 92 54 156 b s
0 156 400 198 b s
195 108 230 128 b s
.7 sg 195 110 230 118 bf
30 11 5 180 270 a 358 11 5 270 360 a s
16 92 m 16 11 l 372 11 l 372 86 l s
372 86 m 356 86 356 86 342 92 c
357 120 30 244 296 a
372 94 l tp 378 92 l 0 -8 rl 372 82 l cp f
400 156 m 0 -40 rl l s
0 74 m 0 13 rl 5 5 rl 11 0 rl 0 -18 rl cp f
42 0 58 5 b s 332 0 348 5 b s
1.5 sl
54 24 m
4{288 0 rl 0 6.96 rm -288 0 rl tp s m 0 6.96 rm}rp
72 306 t
pg
gs
14 24 132 160 b clip newpath
2.5 sl
10 60 m 19 46 rl 15 -20 rl 15 40 rl 15 -20 rl 15 25 rl 15 -50 rl 15 40 rl 15 -20 rl s
2 sl[5 1]0 setdash
10 40 m 19 25 rl 15 -20 rl 20 40 rl s
gr
.5 sl
90 24 m 14 24 l 14 120 l s
[{0}{1 32 tc}{2 15 tc}{3 12 tc}{4 10 tc}]
switchsetting get cvx exec
hv 6 sf 14 12 m (2.0) sh
62 -40 t
pg
.5 sl
hv 6 sf
14 24 m 90 0 rl s
[{{pop 1200 0}rs}
{/sccbatch rs}
{/sccinteractive rs}
{24 16 m(AppleTalk)sh .4 sg 24 24 34 124 bf
.85 sg 44 24 54 84 bf}]
switchsetting get exec
62 -40 t
pg sy 120 sf 17 30 m(p)true charpath
gs .6 sg f gr 0 sg s
sy 9 sf 103 30 m(b)sh
end
end) readonly def
/appletalkopen { -dict- begin^ 9 closescc^ 25 closescc^ (25pletalkopensivesoman) printername^ length^ dup^ (25pletalkopensivesoman) exch^ (:) putinterval^ 1 add^ dup^ (15pletalkopensivesoman) exch^ appletalktype putinterval^ appletalktype length^ add^ (appletalktypesivesoman) exch^ 0 exch^ getinterval^ setappletalkname^ 63 eescratch^ initappletalk^ dup^ 63 eescratch^ ne^ { 63 exch^ seteescratch^ } readonly { pop^ } readonly ifelse^ -dict- /initializing get^ not^ { openappletalk^ /stdout exch^ store^ /stdin exch^ store^ stdin stdout setstdio^ } readonly if^ /sendctrld false store^ /altflag false store^ /stdname (AppleTalk) store^ /commhash hashcommparams store^ end^ } readonly def
/appletalkclose { -1 initappletalk^ pop^ } readonly def
/setnulldevice { nulldevice^ $printerdict /mtx get^ setmatrix^ } readonly def
/setrealdevice { { printerstatus^ dup^ -1 eq^ { pop^ usertime^ 6000 add^ { dup^ usertime^ le^ { pop^ exit^ } readonly if^ } readonly loop^ 2 { resetprinter^ { exit^ } readonly if^ } readonly repeat^ printerstatus^ dup^ -1 eq^ { (%%[ PrinterError: controller not responding ]%%) = flush^ } readonly if^ } readonly if^ } readonly exec^ 126 and^ pagetype^ add^ dup^ -dict- exch^ known^ not^ { pop^ 8 } readonly if^ -dict- exch^ get^ exec^ } readonly def
/initprinter { 1 1 4 { 4 ne^ { 64 sendpcmd^ 0 ge^ { exit^ } readonly if^ } readonly { { printerstatus^ dup^ -1 eq^ { pop^ usertime^ 6000 add^ { dup^ usertime^ le^ { pop^ exit^ } readonly if^ } readonly loop^ 2 { resetprinter^ { exit^ } readonly if^ } readonly repeat^ printerstatus^ dup^ -1 eq^ { (%%[ PrinterError: controller not responding ]%%) = flush^ } readonly if^ } readonly if^ } readonly exec^ pop^ } readonly ifelse^ } readonly for^ } readonly def
/secretdict 0 def
/setstreams { -dict- /jobsource null put^ saveswitch switchsetting^ ne^ { switchclose saveswitch get^ exec^ } readonly if^ /saveswitch switchsetting^ def^ [ { 1200 0 1200 0 setsccstreams } readonly { 9 sccbatch^ 25 sccbatch^ setsccstreams } readonly { 9 sccinteractive^ 25 sccinteractive^ setsccstreams } readonly { appletalkopen } readonly ] saveswitch get^ exec^ } readonly def
/wtimeout 0 def
/baud25 1200 def
/switchopen [ { 1200 0 1200 0 setsccstreams } readonly { 9 sccbatch^ 25 sccbatch^ setsccstreams } readonly { 9 sccinteractive^ 25 sccinteractive^ setsccstreams } readonly { appletalkopen } readonly ] readonly def
/exchdef { exch^ def^ } readonly def
/specialswitch -dict- def
/baud9 1200 def
/execjob { -dict- begin^ /jobstate (idle) def^ /jobname null def^ end^ 0 setblink^ -dict- /doclose true put^ -dict- /quitflag false put^ -dict- -dict- /saveswitch get^ get^ stopped^ disableinterrupt^ { defaulttimeouts^ -dict- begin^ settimeouts end^ clearinterrupt^ { clear^ { countdictstack^ 2 sub^ { end^ } readonly repeat^ } readonly exec^ -dict- begin^ -dict- begin^ newerror { errordict /handleerror get^ exec^ } readonly if^ hashcommparams commhash eq^ stdin status^ and^ doclose and^ errorname /timeout eq^ stdin bytesavailable^ 0 eq^ and^ not^ and^ { (%%[ Flushing: rest of job (to end-of-file) will be ignored ]%%) = flush^ stdin flushfile^ } readonly if^ end^ end^ } readonly if^ -dict- begin^ -dict- /doclose get^ sendctrld and^ { () print^ } readonly if^ flush^ end^ } readonly stopped^ { stdin resetfile^ stdout resetfile^ -dict- /doclose true put^ } readonly if^ -dict- begin^ defaulttimeouts^ settimeouts -dict- /doclose get^ { { stdout closefile^ } readonly stopped^ { stdin closefile^ } readonly stopped^ } readonly if^ disableinterrupt^ 0 0 0 settimeouts clear^ cleardictstack printerclose^ initgraphics^ erasepage^ } readonly def
/switchclose [ { 9 closescc^ 25 closescc^ } readonly { 9 closescc^ 25 closescc^ } readonly { 9 closescc^ 25 closescc^ } readonly { appletalkclose } readonly ] readonly def
/server -array- def
/printerstatus { printerstatus^ dup^ -1 eq^ { pop^ usertime^ 6000 add^ { dup^ usertime^ le^ { pop^ exit^ } readonly if^ } readonly loop^ 2 { resetprinter^ { exit^ } readonly if^ } readonly repeat^ printerstatus^ dup^ -1 eq^ { (%%[ PrinterError: controller not responding ]%%) = flush^ } readonly if^ } readonly if^ } readonly def
/fontname { $idleTimeDict begin dup ROMnames length ge { pop 0 } readonly if ROMnames exch get end } readonly def
/transparent false def
/sccok true def
/settimeouts { -dict- begin^ /waittimeout exchdef /manualfeedtimeout exchdef setjobtimeout^ end^ } readonly def
/altflag true def
/stdin -file- def
/warmedup { { printerstatus^ dup^ -1 eq^ { pop^ usertime^ 6000 add^ { dup^ usertime^ le^ { pop^ exit^ } readonly if^ } readonly loop^ 2 { resetprinter^ { exit^ } readonly if^ } readonly repeat^ printerstatus^ dup^ -1 eq^ { (%%[ PrinterError: controller not responding ]%%) = flush^ } readonly if^ } readonly if^ } readonly exec^ dup^ 0 lt^ exch^ 134217728 and^ 0 eq^ or^ } readonly def
/sendctrld true def
/commhash -1336398848 def
/watchstreams { -dict- begin^ altflag { altin bytesavailable^ 0 ne^ { /stdin /altin dexch /stdout /altout dexch /stdname /altname dexch } readonly if^ } readonly if^ stdin bytesavailable^ 0 ne^ dup^ { stdin stdout setstdio^ -dict- begin^ /jobstate (busy) def^ /jobsource stdname def^ end^ 1 setblink^ } readonly if^ end^ enableinterrupt^ disableinterrupt^ } readonly def
/dexch { dup^ load^ exch^ 2 index^ load^ store^ store^ } readonly def
/stdname (serial 25) def
/altprint { -dict- begin^ altflag { altout 1 index^ writestring^ altout flushfile^ } readonly if^ stdout exch^ writestring^ stdout flushfile^ end^ } readonly def
/altname (serial 9) def
/stdout -file- def
/altout -file- def
/batchidleproc { /idleproc { } readonly def^ -dict- begin^ 0 defaulttimeouts^ pop^ exch^ pop^ 0 settimeouts end^ } readonly def
/altin -file- def