home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 344a.lha / Post_v.02 / init.ps < prev    next >
Encoding:
Text File  |  1990-01-28  |  2.6 KB  |  101 lines

  1. %! Post V0.2 initialisation file
  2. % This file should be run before most programs
  3.  
  4. % Ignore CTRL/D
  5.  
  6. <04> cvn {} def
  7.  
  8. % A dummy status dictionary
  9.  
  10. /statusdict 10 dict dup begin
  11. /waittimeout 0 def
  12. end def
  13.  
  14. % A scratch string
  15.  
  16. /=string 256 string def
  17.  
  18. % The standard input and output files
  19.  
  20. /standardinput (%stdin) (r) file def
  21. /standardoutput (%stdout) (w) file def
  22.  
  23. % Replace showpage for screen viewing
  24.  
  25. /showon   % standard showpage
  26. { userdict /showpage { systemdict /showpage get exec } put
  27. } bind def
  28.  
  29. /showoff  % just reinitialise the graphics
  30. { userdict /showpage { initgraphics } put
  31. } bind def
  32.  
  33. /showwait % wait, then showpage
  34. { userdict /showpage { wait systemdict /showpage get exec } put
  35. } bind def
  36.  
  37. % Wait for the user to view the screen
  38.  
  39. /wait
  40. { standardoutput (Hit Return to continue:) writestring
  41.   standardinput =string readline pop pop
  42. } bind def
  43.  
  44. % Run a program with save and restore
  45.  
  46. /runsave
  47. { /saveobject save def
  48.   run
  49.   saveobject restore
  50. } bind def
  51.  
  52. % Run a program displaying its name
  53.  
  54. /runprog
  55. { dup print (\n) print
  56.   runsave
  57. } bind def
  58.  
  59. % Find a font.  If it is not there we attempt to download it from the
  60. % "PSFonts:" directory; if that fails we substitute DefaultFont if it has
  61. % been defined
  62.  
  63. /findfont
  64. { dup FontDirectory exch known not               % Not in FontDirectory?
  65.   { mark countdictstack 2 sub
  66.         { currentdict end } repeat               % Pop dict stack
  67.     counttomark 1 add index                      % Get the font name
  68.     { (PSFonts:) =string copy pop                % PSFonts:
  69.       =string 8 248 getinterval cvs length 8 add % PSFonts:name
  70.       =string exch 0 exch getinterval            % Truncate to length
  71.       run                                        % Load the font
  72.     } stopped { pop } if                         % Ignore errors for now
  73.     counttomark { begin } repeat pop             % Restore dictionary stack
  74.   } if
  75.   dup FontDirectory exch known not               % Still not there?
  76.   { FontDirectory /DefaultFont known             % DefaultFont defined?
  77.     { pop /DefaultFont } if                      % Substitute DefaultFont
  78.   } if
  79.   systemdict /findfont get exec                  % If errors, will fail
  80. } bind def
  81.  
  82. % Define a dummy font
  83.  
  84. /DummyFont 10 dict dup begin
  85. /FontName /DummyFont def
  86. /FontMatrix [0.001 0 0 0.0001 0 0] def
  87. /FontType 3 def
  88. /FontBBox [0 0 0 0] def
  89. /Encoding StandardEncoding def
  90. /BuildChar { pop pop 0 0 0 0 0 0 setcachedevice } def
  91. /Painttype 0 def
  92. end definefont pop
  93.  
  94.  
  95. % Define a default font
  96.  
  97. FontDirectory /DefaultFont /DummyFont findfont put
  98. %FontDirectory /DefaultFont /Courier findfont put
  99. %FontDirectory /DefaultFont /Times-Roman findfont put
  100.  
  101.