summaryrefslogtreecommitdiff
path: root/dviware/psprint/vms/lw_print.com
blob: fc07e541996e8db7a22debbf51566f30d020735b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
$! This command file is run by PSPRINT/DEV=LW with the following parameters:
$!    P1 = complete file specification
$!    P2 = file format (DVI or PS or TEXT or TWO or WIDE)
$!    P3 = options for PSDVI
$!    P4 = options for PRINT
$!    P5 = /NOTE value ("" if not used)
$!    P6 = /COPIES value (1 if not used)
$!    P7 = /OUTPUT value ("" if not used)
$!    P8 = "bbbb<prep>" where b = Y or N and represents the status of the
$!         boolean qualifiers /DELETE, /LANDSCAPE, /BANNER, /MANUALFEED
$!         and <prep> is the /PREP value, possibly empty
$
$  on control_y then exit
$  set symbol/scope=(nolocal,noglobal)        ! avoid symbol collision
$  delflag    = f$extract(0,1,p8)             ! Y or N
$  landflag   = f$extract(1,1,p8)             ! Y or N
$  bannerflag = f$extract(2,1,p8)             ! Y or N
$  manualflag = f$extract(3,1,p8)             ! Y or N
$  prepfile   = f$extract(4,999,p8)           ! /PREP value
$
$! We arbitrarily restrict /COPIES to <= 100.  Other sites might want to
$! increase this limit or restrict it even further:
$
$  if (p6 .gt. 0) .and. (p6 .lt. 101) then goto CONTINUE
$  write sys$output "Bad /COPIES value.  Specify 1 to 100."
$  exit
$
$  CONTINUE:
$  copies = f$string(p6)
$  job    = f$parse(p1,,,"NAME")
$
$! Build temporary file in sys$scratch.
$! We no longer start with ^D because of problems encountered when
$! a LaserWriter is connected to an X25 pad (due to echoing of ^D).
$! We now assume that any previous job has been terminated.
$! (The LaserWriter server uses ^D to end a job and restore virtual memory.)
$
$  copy tex_ps:lw_header.ps sys$scratch:'job'.tmp
$  tmpfile = f$search("sys$scratch:''job'.tmp")   ! include version number
$  write sys$output -
      "Creating SYS$SCRATCH:''job'.TMP" + f$parse(tmpfile,,,"VERSION")
$
$! tex_ps:lw_header.ps defines @bannerpage and a PostScript error handler.
$! It also stores the current LaserWriter page count; when @bannerpage
$! is finally called we can work out how many pages were printed.
$! Now append various strings that will eventually appear on banner page:
$
$  open/append tmp 'tmpfile'
$  write tmp "/@USER    (USER    : " + f$getjpi(0,"USERNAME")    + ") def"
$  write tmp "/@ACCOUNT (ACCOUNT : " + f$getjpi(0,"ACCOUNT")     + ") def"
$  write tmp "/@JOB     (JOB     : " + job                       + ") def"
$  write tmp "/@NODE    (NODE    : " + f$trnlnm("SYS$NODE")-"::" + ") def"
$  write tmp "/@FILE    (FILE    : " + p1                        + ") def"
$  write tmp "/@FORMAT  (FORMAT  : " + p2                        + ") def"
$  write tmp "/@QUEUED  (QUEUED  : " + f$time()                  + ") def"
$
$! Note that PSPRINT.MOD has prefixed each (,),\ in p5 with \.
$! Such characters should never occur in the above strings!!!
$
$  write tmp "/@NOTE    (NOTE    : " + p5       + ") def"
$
$! The value of #copies will be used by PostScript's showpage operator to
$! print multiple copies of each page.
$! This is very efficient but means that copies are not collated.
$! (Good; we don't want the LaserWriter to be treated like a copier.)
$
$  write tmp "/#copies " + copies + " def"
$
$! Check for /NOBANNER and /MANUALFEED:
$
$  if bannerflag .eqs. "N" then write tmp "/@bannerpage { } def"
$  if manualflag .eqs. "Y" then write tmp -
      "statusdict begin /manualfeed true def end"
$
$! Here are the definitions used in the job prologues:
$
$  write tmp "/dev (LW) def"
$  write tmp "/res 300 def"
$  write tmp "/fspec (" + p1 + ") def"
$  if landflag .eqs. "Y" then write tmp "/land true def"
$  if landflag .eqs. "N" then write tmp "/land false def"
$
$  close tmp
$
$! Each type of job requires its own prologue:
$
$  if p2 .eqs. "DVI"  then append tex_ps:tex.ps, tex_ps:lw_fonts.ps 'tmpfile'
$  if p2 .eqs. "PS"   then append tex_ps:ps.ps   'tmpfile'
$  if p2 .eqs. "TEXT" then append tex_ps:text.ps 'tmpfile'
$  if p2 .eqs. "TWO"  then append tex_ps:two.ps  'tmpfile'
$  if p2 .eqs. "WIDE" then append tex_ps:wide.ps 'tmpfile'
$
$! /PREP qualifier is only allowed for DVI or PS job:
$
$  if (p2 .nes. "DVI") .and. (p2 .nes. "PS") then goto SKIPPREP
$  if prepfile .eqs. "" then goto SKIPPREP
$  write sys$output "Including " + prepfile
$  append 'prepfile' 'tmpfile'
$  SKIPPREP:
$
$! If global.ps exists in the user's current directory then append it
$! to the prologue for a DVI job:
$
$  global = f$search("global.ps")
$  if (global .eqs. "") .or. (p2 .nes. "DVI") then goto SKIPGLOBAL
$  write sys$output "Including GLOBAL.PS"
$  append 'global' 'tmpfile'
$  SKIPGLOBAL:
$
$  if p2 .nes. "DVI" then goto PRINT          ! skip PSDVI if non-DVI file
$
$! Else run PSDVI.
$! psdvifile must be a completely new file spec to avoid file name conflicts:
$
$  ver = 1
$  LOOP:
$  psdvifile = "sys$scratch:psdvi.tmp;''f$string(ver)'"
$  if f$search(psdvifile) .eqs. "" then goto ENDLOOP
$  ver = ver + 1
$  goto LOOP
$
$  ENDLOOP:                                   ! psdvifile does not exist
$  land = ""
$  if landflag .eqs. "Y" then land = "/xsize=297mm /ysize=210mm"   ! rotated A4
$  on warning then goto BADDVI
$  PSDVI 'p1' 'land' /HEADER='tmpfile' -
                     /OUTPUT='psdvifile' -
                     /RES=300 -
                     /FONT="disk$utils:[utilities.tex.300pk]" -
                     /DUMMY="cmr10.300pk" -
                     /NOCONSERVE -
                     /NOREVERSE 'p3'          ! p3 may override above defaults
$  delete/nolog 'tmpfile'
$  rename/nolog 'psdvifile' 'tmpfile'
$  goto PRINT                                 ! output file is okay
$
$! We decide not to print anything if the DVI file has errors.
$! Sites that don't care about wasting paper may wish to do something else.
$
$  BADDVI:
$  delete/nolog 'tmpfile'                     ! delete header
$  if f$search(psdvifile) .nes. "" then -     ! delete bad output file
$     delete/nolog 'psdvifile'
$  write sys$output ""
$  write sys$output "Printing aborted due to error(s). Temporary file deleted."
$  exit
$
$  PRINT:
$  on error then exit
$
$! Now complete tmpfile.
$! For TEXT/TWO/WIDE jobs we must end with ^D.
$! For DVI/PS jobs we must end with tex_ps:lw_trailer.ps before ^D.
$! But if /OUTPUT is used we don't append ^D.
$
$  ctrld = "tex_ps:ctrld.dat"
$  if p7 .nes. "" then ctrld = "tex_ps:empty.ps"
$
$  if (p2 .eqs. "TEXT") .or. (p2 .eqs. "TWO") .or. (p2 .eqs. "WIDE") then -
      append 'p1', 'ctrld'                       'tmpfile'
$  if p2 .eqs. "PS" then -
      append 'p1', tex_ps:lw_trailer.ps, 'ctrld' 'tmpfile'
$  if p2 .eqs. "DVI" then -
      append tex_ps:lw_trailer.ps, 'ctrld'       'tmpfile'
$
$! If /OUTPUT given then rename tmpfile instead of sending it to printer.
$! Use copy & delete rather than rename since tmpfile may be on another disk:
$
$  if p7 .eqs. "" then goto PRINTJOB     ! /OUTPUT not used
$  copy tex_ps:empty.ps, 'tmpfile' 'p7'  ! empty.ps avoids version conflict
$  delete/log 'tmpfile'
$  write sys$output ""
$  write sys$output "Nothing printed. PostScript saved in " + p7
$  exit
$
$  PRINTJOB:
$  print/queue=APPLE/form=postscript/name='job' 'tmpfile'/delete 'p4'
$  if delflag .eqs. "Y" then delete/log 'p1'