%                             PSDOWN.TXT

% This collection of definitions allows a PC-WRITE user to use a PostScript
% printer such as the Apple LaserWriter or the QMS PS-800.  This file 
% must be downloaded to your PostScript printer before printing with PC-Write. 
% To download this file use the DOS PRINT command.  Make sure you have access 
% to the PRINT.COM file.  At the DOS prompt type:

%              PRINT PSDOWN.TXT  <Enter>

% If this is the first time you have invoked the PRINT command, you will be
% prompted for the port your printer is attached to (probably COM1 or COM2).
% Once PSDOWN.TXT is downloaded, you can either print to a file with PC-Write
% and use DOS PRINT for output, or you can use the XON/XOFF capabilities of
% PC-Write by printing to SER1 or SER2.

% REMEMBER, each time you turn your printer on, and want to print using
% PC-Write, you must download the PSDOWN.TXT file as described above.
% Be sure you have selected the Adobe PostScript driver from the MENULAZ
% program.

% This file was written for Quicksoft by George A. Miller.


statusdict begin statusdict /waittimeout 0 put end %set no time out

300 dict begin
/reencsmalldict 12 dict def
/ReEncodeSmall
  {reencsmalldict begin
   /newcodesandnames exch def
   /newfontname exch def
   /basefontname exch def
   /basefontdict basefontname findfont def
   /newfont basefontdict maxlength dict def
   basefontdict
     {exch dup /FID ne
        {dup /Encoding eq
           {exch dup length array copy newfont 3 1 roll put}
           {exch newfont 3 1 roll put} ifelse }
        {pop pop} ifelse } forall
   newfont /FontName newfontname put
   newcodesandnames aload pop
   newcodesandnames length 2 idiv
   {newfont /Encoding get 3 1 roll put} repeat
   newfontname newfont definefont pop end } def

/pcwritevec [
8#321 /Ccedilla
8#322 /udieresis
8#323 /eacute
8#324 /acircumflex
8#325 /adieresis
8#326 /agrave
8#327 /aring
8#330 /ccedilla
8#331 /ecircumflex
8#332 /edieresis
8#333 /egrave
8#334 /idieresis
8#335 /icircumflex
8#336 /igrave
8#337 /Ddieresis
8#340 /Aring
8#342 /Eacute
8#344 /ocircumflex
8#345 /odieresis
8#346 /ograve
8#347 /ucircumflex
8#354 /ugrave
8#355 /ydieresis
8#356 /Odieresis
8#357 /Udieresis
8#360 /aacute
8#362 /iacute
8#363 /oacute
8#364 /uacute
8#366 /ntilde
8#367 /Ntilde
            ] def
/c321 {(\321) fullshow} def
/c322 {(\322) fullshow} def
/c323 {(\323) fullshow} def
/c324 {(\324) fullshow} def
/c325 {(\325) fullshow} def
/c326 {(\326) fullshow} def
/c327 {(\327) fullshow} def
/c330 {(\330) fullshow} def
/c331 {(\331) fullshow} def
/c332 {(\332) fullshow} def
/c333 {(\333) fullshow} def
/c334 {(\334) fullshow} def
/c335 {(\335) fullshow} def
/c336 {(\336) fullshow} def
/c337 {(\337) fullshow} def
/c340 {(\340) fullshow} def
/c342 {(\342) fullshow} def
/c344 {(\344) fullshow} def
/c345 {(\345) fullshow} def
/c346 {(\346) fullshow} def
/c347 {(\347) fullshow} def
/c354 {(\354) fullshow} def
/c355 {(\355) fullshow} def
/c356 {(\356) fullshow} def
/c357 {(\357) fullshow} def
/c360 {(\360) fullshow} def
/c362 {(\362) fullshow} def
/c363 {(\363) fullshow} def
/c364 {(\364) fullshow} def
/c366 {(\366) fullshow} def
/c367 {(\367) fullshow} def
/c245 {(\245) fullshow} def
/c361 {(\361) fullshow} def
/c341 {(\341) fullshow} def
/c242 {(\242) fullshow} def
/c243 {(\243) fullshow} def
/c246 {(\246) fullshow} def
/c343 {(\343) fullshow} def
/c353 {(\353) fullshow} def
/c277 {(\277) fullshow} def
/c241 {(\241) fullshow} def
/c253 {(\253) fullshow} def
/c273 {(\273) fullshow} def
/c225 {(\225) fullshow} def
/c312 {(\312) fullshow} def
/c267 {(\267) fullshow} def
/c264 {(\264) fullshow} def
/c250 {(\250) fullshow} def
/c374 {gsave currentpoint exch pop rightmargin exch sub 16 sub
       0 -6 rmoveto 0 exch rlineto stroke grestore} def
/c375 {gsave currentpoint newpath exch pop rightmargin exch sub 16 sub dup
       0 -6 rmoveto 0 exch rlineto
       0 6 lineheight add rlineto
       neg 0 rlineto closepath gsave stroke grestore
       currentgray .8 setgray fill setgray grestore } def
/Times-Roman /Times-Roman-PCWrite pcwritevec ReEncodeSmall
/Times-Italic /Times-Italic-PCWrite pcwritevec ReEncodeSmall
/Times-Bold /Times-Bold-PCWrite pcwritevec ReEncodeSmall
/Helvetica /Helvetica-PCWrite pcwritevec ReEncodeSmall
/Helvetica-Bold /Helvetica-Bold-PCWrite pcwritevec ReEncodeSmall
/Courier /Courier-PCWrite pcwritevec ReEncodeSmall
/Times-Roman /Times-Roman-PCWrite pcwritevec ReEncodeSmall

/2dup {dup 3 -1 roll dup 4 1 roll exch} def % duplicates top two elements
/command (# ) def % this is the command string
/ccommand (c   ) def % this is the character command string
/checkHeight {scalefont} def % dup 1.15 mul /lineheight exch def 
/#B {/Times-Bold-PCWrite findfont 10 checkHeight setfont} def
/#C {/Times-Roman-PCWrite findfont 8 checkHeight setfont} def
/#D {/Helvetica-Bold-PCWrite findfont 15 checkHeight setfont} def
/#E {/Courier-PCWrite findfont 10 checkHeight setfont} def
/#F {/Courier-PCWrite findfont 12 checkHeight setfont} def
/#I {/Times-Italic-PCWrite findfont 10 checkHeight setfont} def
/#J {/Courier-PCWrite findfont 15 checkHeight setfont} def
/#P {/Times-Roman-PCWrite findfont 10 checkHeight setfont} def
/#Q {/Times-Roman-PCWrite findfont 12 checkHeight setfont} def
/#V {/Helvetica-PCWrite findfont 8 checkHeight setfont} def
/#H { currentpoint 0 lineheight 4 div translate moveto .75 .75 scale} def
/#h { 4 3 div dup scale currentpoint 0 lineheight 4 div neg translate moveto} def
/#L { currentpoint 0 lineheight 6 div neg translate moveto .75 .75 scale} def
/#l { 4 3 div dup scale currentpoint 0 lineheight 6 div translate moveto} def
/#M { .3 setgray } def
/#N {isExecute not {fullshowpage} if} def
/#O {/isCrossout true def} def
/#o {/isCrossout false def} def
/crossout % string CROSSOUT => {backs up and draws an a strike line}
  {stringwidth pop /width exch def
  lineheight 20 div dup mul setlinewidth
  /linewidth lineheight 4 div def
  width neg linewidth rmoveto
  width 0 rlineto gsave stroke grestore 0 linewidth neg rmoveto} def
/#m { 0 setgray } def
/## {(#) fullshow} def
/isUnderline false def
/#U {/isUnderline true def} def
/#u {/isUnderline false def} def
/underline % string UNDERLINE => {backs up and draws an underline}
  {stringwidth pop /width exch def
  lineheight 20 div dup mul dup setlinewidth dup add /linewidth exch def
  width neg linewidth neg rmoveto
  width 0 rlineto gsave stroke grestore 0 linewidth rmoveto} def
/isDoubleUnderline false def
/#W {/isDoubleUnderline true def} def
/#w {/isDoubleUnderline false def} def
/doubleUnderline % string DOUBLEUNDERLINE => {backs up and draws two underline}
  {stringwidth pop /width exch def
  lineheight 20 div dup mul dup setlinewidth dup add /linewidth exch def
  width neg linewidth neg rmoveto
  width 0 rlineto gsave stroke grestore 0 linewidth rmoveto
  /linewidth linewidth 3 mul def
  width neg linewidth neg rmoveto
  width 0 rlineto gsave stroke grestore 0 linewidth rmoveto} def
/isCrossout false def
/isSecondStrike false def
/#S {/isSecondStrike true def} def
/#s {/isSecondStrike false def} def
/secondStrike % string SECONDSTRIKE => {backs up and writes the string again}
  {dup stringwidth pop neg lineheight 20 div dup mul add 0 rmoveto show} def
/#R % leaves the currentpoint on the stack for the begining of a box
   {currentpoint lineheight add 3 -1 roll} def
/#r % assumes the upper left hand corner of a box is on the stack and the
   % current point is the lower right hand corner.  If the halftone is on,
   % (/M) then the box will be filled with a light shading.
   { gsave 3 1 roll currentpoint
     lineheight 20 div dup mul 6 mul sub % lower the box line a bit
     newpath 2dup moveto
     3 1 roll 2dup exch lineto
     4 1 roll 3 -1 roll 2dup exch lineto
     3 -1 roll lineto
     pop pop closepath
     1 setlinewidth
     stroke
     grestore} def
/isPortrait true def
/portrait {initmatrix 22 10 translate
           /rightmargin 576 def
           /isPortrait true def /line startline def } def
/landscape {initmatrix 90 rotate 10 -794 translate
           /rightmargin 756 def
           /isPortrait false def /line startline def } def
/#Y {/pagelength 66 def /lines 0 def portrait leftmargin line moveto} def
/#Z {/pagelength 49 def /lines 0 def landscape leftmargin line moveto} def
/#z {isPortrait {#Y} {#Z} ifelse} def
 % this is home command
/cexecute {/ccommand exch def currentdict ccommand cvn known
           {ccommand cvx exec}
           {(*** error *** unknown character command:) = ccommand =} ifelse} def
/#G % will show a special character, eg. #G c321. will display the cedilla
    %  IMPORTANT: a period must follow the number.
   {(.) search { cexecute pop } if} def
/#A % adjusts the lineheight. Eg. #A 12. will set the lineheight to 1/12th
   % of an inch.  IMPORTANT: a period must follow the number.
   {(.) search { cvi 72 exch div /lineheight exch def pop } if} def
/#a % moves the current point to the right.  Eg. #a 12. will insert 1/12th
   % of an inch of white space.  IMPORTANT: a period must follow the number.
   {(.) search { cvi 72 exch div 0 rmoveto pop } if} def
/isExecute false def     %flag for the execute mode
/#T {/isExecute true def} def
/#t {/isExecute false def} def
/lineheight 12 def
/leftmargin 0 def
/startline 760 def
/line startline def
/lines 0 def
/pagelength 66 def
/buffer 2000 string def
/final {{dup (*end) eq {false} {true} ifelse} {false} ifelse} def
/fullshowpage {showpage isPortrait {#Y} {#Z} ifelse} def
/fullshow % executes string or shows then checks for underline et cetera
  { isExecute {cvx exec} { dup show
   isUnderline {dup underline} if
   isDoubleUnderline {dup doubleUnderline} if
   isCrossout {dup crossout} if
   isSecondStrike {dup secondStrike} if
  pop} ifelse} def
/execute { command 1 3 -1 roll put currentdict command cvn known
           {command cvx exec}
           {(*** error *** unknown command:) = command =} ifelse} def
/strip { % strips off the string before # and prints it then executes
         % the character following the #
       (#) search
       {fullshow pop
          dup length 1 gt
          {dup 0 get exch dup length 2 sub 2 exch getinterval exch}
          {0 get () exch}
          ifelse execute}
       {fullshow () } ifelse
       } def
/showBuffer % processes the string on the top of the stack
           {{dup length 0 le {exit} if strip } loop pop } def
/IncLine {line lineheight sub /line exch def
          lines 1 add dup pagelength ge
         {pop 0 fullshowpage /line startline def} if /lines exch def} def
/create {leftmargin line moveto showBuffer IncLine} def
/anotherline {input buffer readline pop create} def % final {exit} ifelse
/input (%stdin) (r) file def
/*start  {/line startline def /lines 0 def #E #Y %default font and orientation
          {anotherline} loop } def

*start


