! PRINT {RWT, January 1991} adapted from the recently revised ! COPY program which automatically switches between filestores %option "-low-nodiag-nocheck" %include "inc:fs.imp" %include "inc:util.imp" %include "inc:fsutil.imp" ! Ether comms %routine ackwait(%integer port) %integer bit=1<marktime %repeatuntil cputime>deadline printline("No ACK/NAK"); %signal 9 %end %routine dtxwait(%integer port) %integer bit=1<marktime %repeatuntil cputime>deadline printline("No response"); %signal 9 %end %predicate nacked(%integer port) %integer bit=1< server.("::").rawfilename %start retried = 1 {no retrying if server specified explicitly} k = charno(server,1)&95 %unless server="" %if length(server)=1 %and 'A'<=k<='Z' %start dte = dtetable(k) %else dte = 0 %while server#"" %cycle k = charno(server,1); server = substring(server,2,length(server)) %if '0'<=k<='9' %start dte = dte<<4-'0'+k %else k = k&95; %exitunless 'A'<=k<='F' dte = dte<<4-'A'+k+10 %finish %repeat %finish %if dte=0 %start no: select(original); printstring("Unknown server ") printline(filename); %result = 0 %finish %finish %finish rdte = dte; port = allocate port; ->no %if port=0 select(port); open(1,rawfilename); selectoutput(0) %result = port %end %routine transfer %bytearray buf(0:4095) %integer n=0,k=nl,i %on 9 %start closeinput select(outport); selectoutput(1) %for i = 0,1,n-1 %cycle k = buf(i); printsymbol(k) %repeat newline %unless k=nl selectoutput(0) %return %finish %cycle select(inport); selectinput(1) n = 0 %cycle readsymbol(buf(n)); n = n+1 %repeatuntil n=4096 select(outport); selectoutput(1) %for i = 0,1,n-1 %cycle k = buf(i); printsymbol(k) %repeat %repeat %end ! Draw box around text %constinteger maxwidth=80,maxheight=71 %string(maxwidth)%array line(1:maxheight) %integer p=1,max=0 %routine newbox p = 1; max = 0 %end %routine add(%string(maxwidth)s) ! Add line S to the box %returnif p>maxheight-2 %or length(s)>=maxwidth-2 max = length(s) %if length(s)>max line(p) = s; p = p+1 %end %routine enbox(%integer margin) ! MARGIN is number of spaces wanted between text and horizontal border. ! For vertical equivalent, user is obliged to call ADD("") appropriately. ! For multiple borders, ENBOX may be called repeatedly. %integer i %string(maxwidth)%name s %returnif p>maxheight-1 %or (1+margin)*2+max>=maxwidth %for i = p-1,-1,1 %cycle s == line(i+1) s = "|" s = s." " %while length(s)<=margin s = s.line(i) s = s." " %while length(s)<=2*margin+max s = s."|" %repeat s == line(1) s = "+"; s = s."-" %while length(s)<=2*margin+max s = s."+" line(p+1) = s p = p+2; max = (1+margin)*2+max %end %routine printbox(%integer pos) ! POS>0 aligns it to the left, with an extra POS-1 spaces. ! POS<0 aligns it to the right, (-POS)-1 spaces from the RH margin. ! POS=0 aligns it to the middle. %integer i %if pos>0 %then pos = pos-1 - %elseif pos<0 %then pos = pos-max+maxwidth+1 - %else pos = (maxwidth-max)>>1 %for i = 1,1,p-1 %cycle spaces(pos); printstring(line(i)); newline %repeat %end %routine print(%string(255)file) inport = access(openinput,file); %returnif inport=0 outport = access(openoutput,"c::lp:!".currentuser) %if outport=0 %start select(inport); selectinput(1); closeinput select(original); %return %finish printstring("Printing ".file); newline select(outport); selectoutput(1) setparam(lpi,lpival) setparam(cpi,cpival) setparam(qual,qualval) transfer selectoutput(1) setparam(lpi,lpinormal) %unless lpival=lpinormal setparam(cpi,cpinormal) %unless cpival=cpinormal setparam(qual,qualnormal) %unless qual=qualnormal %unless banner=0 %start printsymbol(12) printstring("THIS SHOULD BE THE FIRST LINE ON THE PAGE"); newlines(3) ! 3 lines so far newbox add("IMPORTANT:") add("Please check whether the top-of-form is set correctly, with the above") add("'first line' appearing immediately adjacent to, but not overlapping,") add("the inter-sheet perforations. If it is wrong, PLEASE CORRECT IT NOW,") add("as follows:") add("* Raise the hood.") add("* Raise the platen lever on your left. This unlocks the tractor feed") add(" mechanism, allowing you to adjust the paper alignment by rotating") add(" the black knob on your right.") add("* Move the paper until the inter-sheet perforations are in line with") add(" the middle of the black plastic 'gates' which hold the paper to the") add(" tractor feed mechanism. A little 'nose' poking out of each of the") add(" two gates marks the place.") add("* Lower the platen lever to re-engage the motor drive.") add("* NOW FOR THE CLEVER BIT: While holding down the reset button, press") add(" the form feed button once. This is a special 'partial-form-feed'") add(" instruction which tells the printer to advance the paper by the") add(" difference between the sheet length and the distance from the") add(" top-of-form position and the alignment 'noses'.") add("* Lower the hood. Press the on-line button.") enbox(1); printbox(0) ! plus 20 plus 2 = 25 lines so far newlines(50-25) ! 50 lines so far newbox select(original) add(datetime) add("The file just printed was ".file) add("It was sent by ".currentuser) select(outport) enbox(1); enbox(1); enbox(1); printbox(0) %finish closeoutput; selectoutput(0) %end %on 0 %start select(original); selectoutput(0); printstring("*Aborted") select(inport); select(original) %if inport=0 selectinput(1); closeinput select(outport); select(original) %if outport=0 selectoutput(1); resetoutput; closeoutput select(original); selectoutput(0); newline %return %finish portinfo(i) = 0 %for i = 1,1,31 portinfo(original) = cur therest = cliparam."," %while therest -> thisone.(",").therest %cycle filename = "" defineparam("File",filename,0) defineenumparam("c10,c12,c13,c17 - cpi",cpival,0) defineenumparam("l3,l4,l6,l8 - lpi",lpival,0) defineenumparam("draft,,letter - quality",qualval,0) defineenumparam("nobanner,banner - trailer",banner,0) processparameters(thisone) %continueif filename="" filename = currentdirectory.":".filename %unless filename -> (":") print(filename); select(original) %repeat %for i = 1,1,31 %cycle select(i); disconnect %unless i=original %repeat select(original) %end