%!PS-Adobe-3.0 %%Pages: 1 %%EndComments % % % Automatic translation of .dcw file to postscript % % Debugging.... % const debuglm: left margin of debug messages /debuglm 0.5 72 mul def % const debugtop: top of debug messages - 11 inches up. /debugtop 11 72 mul def % const debugdown: how far to go down each line /debugdown 20 def % debugorigin(): % move to debugging origin /debugorigin { debuglm debugtop moveto (Debugging log:) show newline } bind def % debugnv( name, value ); % display name and value on a debug line. % keep this as it's so much simpler than debug() below % and also debug() has commented out invocations to % this throughout it:-) /debugnv { % initially: stack top: value, name 30 0 rmoveto exch % stack top: name, value show % show name, stack top: value (: ) show 50 string cvs show % show convert_to_string(value) newline } bind def % debugsay( string, array_of_pairs ); % display a single message, combining the initial string and then % every pair of items (variable,string) in with no separators. % eg debugsay( (x:), [ x (, y:) y (, z:) z ()] ) produces % "x: value_of_x, y: value_of_y, z: value_of_z" /debugsay { 6 dict begin % next N items defined are in a local dictionary /array exch def % localize parameter name, removing it from stack /initstr exch def % localize parameter name, removing it from stack /len 0 def % local variable - length of array /pos 0 def % local variable - position in array /name () def % local variable - an array element /value () def % local variable - next array element 30 0 rmoveto /len array length def initstr 50 string cvs show % for pos = 0 to $#array step 2 0 2 len 1 sub { /pos exch def % (pos) pos debugnv % $name = $array[$pos]; /name array pos get def % (name) name debugnv % $value = $array[$pos+1]; /value array pos 1 add get def % (value) value debugnv name 50 string cvs show value 50 string cvs show } for newline end % local dictionary destroyed here } def % newline(); % go to left margin of next line for debug messages /newline { currentpoint debugdown sub % decrement Y pos exch pop % drop old X debuglm exch % form (debuglm,Y) on stack moveto % go there! } def % str = i2s(n): % convert n to a string /i2s { 50 string cvs } def % result = append( string1, string2 ) % Concatenates two strings together. Some languages % already know how to do stuff like this!!! /append { % Initial stack: s1 s2 <-- top of stack 2 copy % s1 s2 s1 s2 length % s1 s2 s1 len(s2) exch % s1 s2 len(s2) s1 length add % s1 s2 len(s1)+len(s2) string dup % s1 s2 r r 4 2 roll % r r s1 s2 2 index % r r s1 s2 r 0 % r r s1 s2 r 0 3 index % r r s1 s2 r 0 s1 putinterval % strcpy( r+0, s1 ) % r r s1 s2 exch % r r s2 s1 length % r r s2 len(s1) exch % r r len(s1) s2 putinterval % strcpy( r+len(s1), s2 ) % return r } bind def %%Page: 1 1 %%PageOrientation: Portrait /Helvetica-Bold findfont 13 scalefont setfont debugorigin /n 20 def /found 0 def /i 100 def { /lower i cvi 10 mod def /upper i def { upper 9 le { exit } if /upper upper 10 div int def } loop /div 10 upper mul lower add def i cvi div mod 0 eq { %say "$i" () [i ()] debugsay /found found 1 add def } if found n ge { exit } if /i i 1 add def } loop showpage