siegel@hc.DSPO.GOV (josh Siegel) (04/24/89)
% Hope this helps...
% Take this file and do a "cat <file-name> | psh | psh | psh | psh | psh"...
% It writes itself out...
% A quicky to print NeWS routines out of memeory to a file. Next,
% I have to write a all-NeWS postscript indenter so that it looks
% nice on the other end.
% NeWS-print 0.9
% Written by Josh Siegel
/fixstring { % Fix the problem printing the magic characters
% This was done this way so that I didn't need to train my code to
% handle dictionaries... I will do it later...
userdict /string-magic known not {
userdict /string-magic
dictbegin
(\b) (\\b) def
(\f) (\\f) def
(\n) (\\n) def
(\r) (\\r) def
(\t) (\\t) def
(\() (\\\() def
(\)) (\\\)) def
(\\) (\\\\) def
dictend
put
} if
10 dict
begin
/out () def
{
(0) dup 0 4 -1 roll put
dup string-magic exch known {
string-magic exch get
} if
out exch append /out exch def
} forall
out
end
} def
/stringer { % proc => string
{
dup type cvlit
{
/arraytype {
/the_string the_string ( { ) append store
stringer
/the_string the_string ( } ) append store
}
/nametype {
dup xcheck {
255 string cvs the_string ( ) append exch
append /the_string exch store
} {
255 string cvs
/the_string the_string ( /) 4 -1 roll append
append store
} ifelse
}
/operatortype {
255 string cvs dup length 2 sub 1 exch getinterval
the_string ( ) append exch append /the_string exch store
}
/stringtype {
fixstring
( \() exch (\) ) append append the_string
exch append /the_string exch store
}
/Default {
255 string cvs the_string ( ) append exch
append /the_string exch store
}
} case
} forall
} def
% wrap the function up
/wrapper { % proc => string
10 dict
begin
/proc exch def
/the_string (/) proc 255 string cvs ( { \n) append append def
proc load stringer the_string ( } def \n) append
end
} def
% a example... You can feed this into psh, then feed out_file
% into psh and both "out_file's" will be the same.
/write_out {
/fixstring wrapper print
/stringer wrapper print
/wrapper wrapper print
/write_out wrapper print
(write_out\n) print
} def
write_out
--
Josh Siegel (siegel@hc.dspo.gov)
"Oh well.. I guess I will just bury my guns... sigh.. " - Standard Gun Owner