From: MRL@PFC.MIT.EDU (MARK LONDON)
Newsgroups: comp.os.vms
Subject: LASER New (different) LASER symbiont. 4/7
Date: 22 Aug 92 16:22:00 GMT
Distribution: world
Organization: The Internet

-+-+-+-+-+-+-+-+ START OF PART 4 -+-+-+-+-+-+-+-+
X`09static $DESCRIPTOR(key, "TRAILER");
X`09struct dsc$descriptor_s temp = `7B0, DSC$K_DTYPE_T, DSC$K_CLASS_S, 0`7D;
X`09struct dsc$descriptor_s date=`7B23, DSC$K_DTYPE_T, DSC$K_CLASS_S, time`7D
V;
X`09struct dsc$descriptor_s msgd =
X`09`09`7Bsizeof(message)-1, DSC$K_DTYPE_T, DSC$K_CLASS_S, message`7D;
X`09static struct dsc$descriptor_s zero =
X`09`09`09`09`7B1, DSC$K_DTYPE_T, DSC$K_CLASS_S, &z`7D;
X
X/*  Check to see if we need a trailer. */
X
X`09getitemdescrip(SMBMSG$K_SEPARATION_CONTROL, &temp, TRUE);
X`09ctl = * (long*) temp.dsc$a_pointer;
X
X`09/*  save page count if first file of job */
X`09if (ctl & SMBMSG$M_FIRST_FILE_OF_JOB) jobstart = startpage;
X`09
X`09if (which == 0) `7B`09`09`09/* if flag page */
X`09`09if ((ctl & (SMBMSG$M_FILE_FLAG `7C SMBMSG$M_JOB_FLAG `7C
X`09`09`09SMBMSG$M_FILE_BURST `7C SMBMSG$M_JOB_BURST))  == 0) /* if no flags
V */
X`09`09`09return;
X
X`09`09if ((ctl & (SMBMSG$M_FILE_BURST `7C SMBMSG$M_FILE_FLAG)) == 0) /* if j
Vob only */
X`09`09`09if ((ctl & SMBMSG$M_FIRST_FILE_OF_JOB) == 0) /* if not first file *
V/
X`09`09`09`09return;
X`09`7D
X`09else `7B`09`09`09`09`09/* trailer page */
X`09`09if (((ctl & (SMBMSG$M_JOB_TRAILER `7C SMBMSG$M_FILE_TRAILER))== 0) &&
X`09`09`09((stop_task `7C stop_reason) == 0)) return;
X
X`09`09if ((stop_task `7C stop_reason) == 0) /* if no error */
X`09`09`09if ((ctl & SMBMSG$M_FILE_TRAILER) == 0) /* if job only */
X`09`09`09`09if ((ctl & SMBMSG$M_LAST_FILE_OF_JOB) == 0) /* if not last file
V */
X`09`09`09`09`09return;
X`09`7D
X`09
X/*  send the trailer module from the library */
X
X`09WRITELASER(&4,1)`09`09`09/* leading EOF */
X`09if(!writemodule(key)) return;
X
X`09getitemdescrip(SMBMSG$K_USER_NAME, &temp, TRUE);
X`09strncpy(user, temp.dsc$a_pointer, temp.dsc$w_length);
X`09user`5Btemp.dsc$w_length`5D = 0;
X
X        if (getitemdescrip(SMBMSG$K_JOB_NAME, &temp, FALSE))
X                strncpy(job, temp.dsc$a_pointer, temp.dsc$w_length);
X        else
X                temp.dsc$w_length = 0;
X`09job`5Btemp.dsc$w_length`5D = 0;
X
X`09getitemdescrip(SMBMSG$K_FILE_SPECIFICATION, &temp, TRUE);
X`09strncpy(file, temp.dsc$a_pointer, temp.dsc$w_length);
X`09file`5Btemp.dsc$w_length`5D = 0;
X
X`09lib$date_time(&date);
X`09time`5B23`5D = 0;
X
X`09sprintf(buf,
X`09 "setuppage (%s) h-job (%s) h-user (%s) h-file (%s) h-time  ",
X`09  job, user, file, time);
X`09WRITELASER(buf,strlen(buf))
X`09
X/*  only print page count on last trailer page */
X`09
X`09if ((which == 1) && (ctl & SMBMSG$M_LAST_FILE_OF_JOB)) `7B /* if last one
V */
X`09`09sprintf(buf, "(%d) h-pages ", jobstart);
X`09`09WRITELASER(buf,strlen(buf))
X`09`7D
X`09
X`09
X`09if ((which == 1) && (stop_task `7C stop_reason)) `7B
X`09`09if (stop_task) stop = stop_task; else stop = stop_reason;
X`09`09msglen = 0;`09`09`09/* in case of error */
X`09`09stat = sys$getmsg(stop, &msglen, &msgd, 15, 0);
X`09`09checkstat(stat,"$getmsg");
X`09`09message`5Bmsglen`5D = 0;
X`09`09sprintf(buf, "(%s) h-error ", message);
X`09`09WRITELASER(buf,strlen(buf))
X`09`7D
X`09
X`09if (userlog > 0) `7B`09`09`09/* if log file */
X`09`09str$append(&savelog, &zero);
X`09`09for (cp=savelog.dsc$a_pointer; *cp; cp+=strlen(cp)+1) `7B
X`09`09`09sprintf(buf, "(%s) h-logline\n", cp);
X`09`09`09WRITELASER(buf,strlen(buf))
X`09`09`7D
X`09`7D
X`09
X`09sprintf(buf, " showpage \004");
X`09WRITELASER(buf,strlen(buf))
X`7D
X
X
X/**`09writemodule - write module from library.
X*
X*`09return:`09TRUE if module written, else FALSE.
X*/
Xwritemodule(key)
Xstruct dsc$descriptor_s key;
X`7B
X`09int stat, len;
X`09int library_index;
X`09long txtrfa`5B2`5D;
X`09char inbuf`5B255`5D;
X`09struct dsc$descriptor_s inbufdes = `7Bsizeof(inbuf), DSC$K_DTYPE_T, DSC$K
V_CLASS_S, inbuf`7D;
X`09struct dsc$descriptor_s outbufdes;
X
X`09if (library_spec.dsc$a_pointer == 0) return FALSE;
X`09
X`09stat = lbr$ini_control(&library_index, &LBR$C_READ, &LBR$C_TYP_TXT, 0);
X`09checkstat(stat, "ini_control");
X
X`09stat = lbr$open(&library_index, &library_spec, 0, 0, 0, 0, 0);
X`09checkstat(stat, "open");
X
X`09stat = lbr$lookup_key(&library_index, &key, txtrfa);
X`09if ((stat & 1) != 1) `7B`09`09`09/* if bad key */
X`09`09stat = lbr$close(&library_index);
X`09`09checkstat(stat, "close library");
X`09`09return FALSE;
X`09`7D
X
X`09do `7B
X`09`09stat = lbr$get_record(&library_index, &inbufdes, &outbufdes);
X`09`09if (stat == RMS$_EOF) break;
X`09`09
X`09`09len = outbufdes.dsc$w_length;
X`09`09inbuf`5Blen++`5D = '\r';
X`09`09inbuf`5Blen++`5D = '\n';
X
X`09`09WRITELASER(inbuf,len)
X`09`09
X`09`7D while (1);
X
X`09stat = lbr$close(&library_index);
X`09checkstat(stat, "close");
X`7D
X
X
X/**`09writeuserlog - write line to user log file.
X*/
Xwriteuserlog()
X`7B
X`09int stat;
X`09static struct dsc$descriptor_s temp =
X`09`09`09`09`7B0, DSC$K_DTYPE_T, DSC$K_CLASS_S, 0`7D;
X
X`09if (userlog < 0) return;`09`09/* if no log file */
X`09
X`09sys$setast(0);
X`09
X`09userlog++;`09`09`09`09/* bump flag */
X
X`09log_rab.rab$l_rbf = laser_buf;
X`09log_rab.rab$w_rsz = strlen(laser_buf);
X
X`09stat = sys$put(&log_rab, 0, 0);
X`09
X`09if (userlog <= 5) `7B`09`09`09/* save first 5 lines */
X`09`09temp.dsc$w_length = strlen(laser_buf) + 1;`09/* incl 0 */
X`09`09temp.dsc$a_pointer = laser_buf;
X`09`09str$append(&savelog, &temp);
X`09`7D
X
X`09sys$setast(1);
X
X`09checkstat(stat, "write log");
X`7D
$ CALL UNPACK LASER.C;253 1862296019
$ create 'f'
X$ LINK LASER,LASER_ERR,TEK2PS,SYS$INPUT/OPT/DEBUG
XSYS$SHARE:VAXCRTL/SHARE
$ CALL UNPACK LASER.DBG;4 741617884
$ create 'f'
X1 Postscript
XThis help describes how to print to postscript printers.  This only
Xapplies to queues not running DEC's software.  The two have similarities,
Xbut the non-DEC software is faster, particularly when printing tektronix
Xfiles.  Tektronix plots also are printed with a smaller line width,
Xwhich can be changed to any value, if so desired.  The software also
Xattempts to determine if the file is postscript or tektronix rather than
Xrequiring the user to specify that information on the PRINT command.`20
XYou can determine what software your printer queue is running by using
Xthe SHOW QUEUE/FULL command.  If it shows  PROCESSOR=CPS$SMB, then it is
XDEC, and you should refer to the main help topic PRINT_Parameters.`20
X
XThe parameters subtopic describes parameters that are similar to DEC's
Xparameters and are mainly not dependent on the file type, such as`20
XPAGE_LIMIT and NUMBER_UP.  The forms subtopic describes file dependent
Xparameters such as margins for text files.
X
XFor parameters which are general to all printer queues, see the main
Xhelp topic PRINT.
X2 Parameters
XThe PRINT command accepts the /PARAMETERS qualifier to specify functions
Xwhich emulates the DECprint Printing Services software for printers. `20
X
XFormat:
X
X$ PRINT/PARAMETERS=(parameter`5B,...`5D)  file-spec
X
XIf you specify only one parameter, you can omit the parentheses.  If you
Xspecify two or more parameters, separate them with commas and enclose the
Xset in parentheses.
X3 DATA_TYPE
X     DATA_TYPE=data-type-name
X
XSpecifies the file type. `20
X
XData-type-name can be ANSI, ASCII (same as ANSI), TEK4014, PS or POSTSCRIPT
X(same as PS).  If you do not specify DATA_TYPE, it tries to determine if`20
Xthe file is TEK4014 or POSTSCRIPT.  Otherwise, it defaults to the data type`
V20
Xassociated with the print queue.  If there is no data type associated with
Xthe print queue, the data type defaults to ANSI.  ANSI is used for`20
Xprinting text.  It does not emulate an LN03.
X3 MESSAGES
X   MESSAGES=KEEP
X
XSpecifies what happens to job-generated event messages.
X
XMessages are printed on the job log page.  MESSAGES=KEEP specifies that`20
Xmessages are recorded in a file named <printfilespec>.LASER_LOG.
X3 PAGE_LIMIT
X   PAGE_LIMIT=(`5Blower-limit,`5D`5Bupper-limit`5D)
X
XSpecifies the numbers of the first and last pages to print.
XHeader, trailer, and burst pages are not included in the count.
X
XIf you omit the lower limit, printing starts at the first page of the
Xjob.  If you omit the upper limit, printing continues to the end of the
Xjob.  You can omit the parentheses if you specify only the upper limit.
XThe maximum value for upper-limit is 10000.
X
XThe default is to print the entire job.
X3 PAGE_ORIENTATION
X
X       PAGE_ORIENTATION=logical-orientation
X
XSpecifies the orientation of printed output on the logical page.
X
XLogical-orientation can be PORTRAIT or LANDSCAPE.  The default is`20
XPORTRAIT.
X
XIf the DATA_TYPE is POSTSCRIPT this parameter is ignored.  If the DATA_TYPE
Xis TEK4014, the default is LANDSCAPE.
X3 NUMBER_UP
X   NUMBER_UP=n
X
XNUMBER_UP specifies the maximum number of pages you can print per sheet.
XThis is the number of pages per sheet that will actually print.  (A sheet is
Xa physical piece of paper.  A page is an image, which you would generally
Xprint on a single sheet.)  A border is printed around each page.  You can
Xdisable this by adding the parameter BORDER=NONE.  `20
X
XThe value n can be from 1 to 16.  The default is NUMBER_UP=1.
X3 SIDES
X   SIDES=sides-layout-value
X
X   Specifies whether your job will print on two sides of a sheet,`20
X   and whether it will print in tumble mode. Sides-layout-value can be:
X   `20
X   2, TWO, or           Your job is printed on both sides of a sheet.
X   TWO_SIDED_DUPLEX
X
X   TUMBLE or            Your job is printed on both sides of the sheet,
X   TWO_SIDED_TUMBLE     and alternating pages are rotated 180`B0. `20
X2 Forms
XThe following forms are defined for use with postscript printers.
XSome forms have special parameters associated only with that form, and
Xare listed following the form name.  They are passed as follows on the
Xprint command:
X
X                   /param=(parameter=value,...)
X
XUse the SHOW QUEUE/FULL command to see the default form for your queue.
X
XForm        Parameters
X
XHEADERS     Print file with filename and page number headers.
X            ncopies:   Number of copies. (default: 1)
X                       Note:  This produces uncollated copies vs.
X                       collated copies produced by the /COPY qualifier.`20
X            fsize:     Font size in points. (default: 10)
X            wide:      If true set landscape mode. (default: false)
X            title:     If false suppress the page headers. (default: true)
X            ncolumns:  Number of columns. (default: 1)
X            linelimit: Max number of lines per page. (default: 77)  `20
X            font:      Font type. (default: Courier)  Must be specified
X                       as follows: font="(fontname)".
X            left:      Left margin. (default: 1. inch, .4 for landscape)
X            right:     Right margin. (default: .25 inch)
X                       (has affect only when used with ncolumns
X                       or alternate.)
X            top:       Top margin. (default: .61 inch, .4 for landscape)
X            bottom:    Bottom margin. (default: .5 inch, .3 for landscape)
X            alternate: If true, alternate left and right margins at
X                       end of page for printing double sided output.
X                       (default: false)
X
XLETTER      Same as HEADERS except default title to false.
X
XLANDSCAPE   Same as LETTER except default wide to true.
X
X2UP         Same as LANDSCAPE except default ncolumns to 2.
X
XTEK4014     Print a tektronix file. `20
X            lw: Line width. (default: 1.5 points)
X
XPAINT       Print a MacPaint image.
X            ncopies:   Number of copies. (default: 1)
X            scale:     Scale factor. (default: 4, recommended: 1-4)`20
X
XBITIMAGE    Print an uncompressed image.
X            ncopies:  Number of copies. (default: 1)
X            scale:    Scale factor. (default: 1)
X            xsize:    Number of pixels in a row. (default: 512)
X            ysize:    Number of pixel columns. (default: 512)
X            pxlwid:   Number of bits in a pixel, default 1, values: 1,2,4,8
X
XZETA        Print a zeta plot file.
X            ncopies:  Number of copies. (default: 1)
X            scale:    Scale factor. (default: 1)
X            zFont:    false - selects Helvetica font for internal character
X                      true -  (default) uses Zeta characters
X            penscale: Scaling factor for pen point (default: 1)
X            usepens:  false - (default) ignore alternate pen select
X
XExample:
X
X   $ PRINT/QUEUE=ALW/FORM=HEADERS/PARAM=(LINELIMIT=66,FSIZE=14) STUFF.TXT
X   Prints STUFF.TXT with a font size of 14 and a limit of 66 lines per page.
X2 Spooling
XSpooled file names have the following syntax:
X
X                     _FormName._ParameterList
X
Xwhere ParameterList is a list of parameters separated by "_". Keywords
Xare separated from their values with "-". Example:
X
X             $ copy thing.mpt alw:_paint._scale-4_ncopies-5
$ CALL UNPACK LASER.HLP;17 302857652
$ create 'f'
X$ LINK LASER,LASER_ERR,TEK2PS,SYS$INPUT/OPT
XSYS$SHARE:VAXCRTL/SHARE
$ CALL UNPACK LASER.LNK;10 1445078657
$ create 'f'
Xlaser,laser_err,sys$share:vaxcrtl.exe/share
$ CALL UNPACK LASER.OPT;1 606016596
$ create 'f'
X`09.Title`09`09LASER error messages
X`09.Facility`09LASER,1/prefix=LASER$_
X        .Ident`09`09'LASER Version 1.0'
X
X`09.Severity`09INFORMATIONAL
X`09CREATELOG`09<Error log file created>
X`09STALLED`09`09<Printer queue %s is stalled>
X`09RESUMED`09`09<Printer queue %s has resumed printing>
X`09STARTJOB`09<Job %s, entry %d started on queue %s>
X`09JOBID`09`09<for job %s, entry %d on queue %s>
X`09ERROR`09`09<Error received from printer:>
X`09USERDATA`09<>
X        TIMEOUT`09`09<Server can not be connected to on queue %s>
X        ABORT`09`09<Connection rejected on queue %s due to LAT rejection cod
Ve %d>
X`09.Severity`09FATAL
X`09MAXITEMS`09<Too many items in item list>
X`09ITEMNOTFOUND`09<Item not in item list>
X`09STREAMNOTSTART`09<Stream was not started>
X`09TOOMANYTABS`09<Too many tabs in input record>
X`09FLUSHED`09`09<Rest of Job (to EOJ) will be ignored>
X`09SETUPNOTFOUND`09<Setup module not found in library>
X`09INVPARAM`09<Invalid parameter specified>
X
X`09.End
$ CALL UNPACK LASER_ERR.MSG;12 1829989627
$ create 'f'
X#define`09LBR$C_TYP_UNK`090
X#define`09LBR$C_TYP_OBJ`091
X#define`09LBR$C_TYP_MLB`092
X#define`09LBR$C_TYP_HLP`093
X#define`09LBR$C_TYP_TXT`094
X#define`09LBR$C_TYP_SHSTB`095
X#define`09LBR$C_TYP_DECMX`095
X#define`09LBR$C_TYP_RDEC`09127
X#define`09LBR$C_TYP_USRLW`09128
X#define`09LBR$C_TYP_USRHI`09255
X#define`09LBR$C_FLUSHDATA`091
X#define`09LBR$C_FLUSHALL`090
X#define`09LBR$C_MAXRECSIZ`092048
X#define`09LBR$C_PAGESIZE`09512
X#define`09LBR$C_HASHSIZE`09512
X#define`09LBR$C_TEXTPAGE`09508
X#define`09LBR$C_DEXTQ`0950
X#define`09LBR$C_MAXCTL`0916
X#define`09LBR$C_MAXHDRSIZ`09128
X#define`09LBR$C_DEFENTALL`09300
X#define`09LBR$C_RETRYOPEN`0930
X#define`09LBR$C_RETRYWAIT`091
X#define`09LBR$C_MINREAD`092
X#define`09LBR$C_MAXREAD`0950
X#define`09LBR$C_MEMXTRA`0950
X#define`09LBR$C_PUTBUFSIZ`0930
X#define`09LBR$C_FLSHBFSIZ`091
X#define`09LBR$C_MAXIDXRD`0920
X#define`09LBR$C_MAXKEYLEN`09128
X#define`09LBR$C_MAXLUHREC`0932768
X#define`09LBR$C_CREATE`090
X#define`09LBR$C_READ`091
X#define`09LBR$C_UPDATE`092
X#define`09LBR$C_MAXFUNC`092
X#define`09LBR$S_LBRDEF`0916
X#define`09LBR$L_IC_CTLTBL`094
X#define`09LBR$L_IC_FUNC`098
X#define`09LBR$L_IC_TYPE`0912
X#define`09LBR$S_LBRDEF1`0932
X#define`09LBR$L_OP_CTLTBL`094
X#define`09LBR$L_OP_FNS`098
X#define`09LBR$L_OP_CREOPT`0912
X#define`09LBR$L_OP_DNS`0916
X#define`09LBR$L_OP_RLFNA`0920
X#define`09LBR$L_OP_RNS`0924
X#define`09LBR$L_OP_RNSLEN`0928
X#define`09LBR$S_LBRDEF2`098
X#define`09LBR$L_CL_CTLTBL`094
X#define`09LBR$S_LBRDEF3`0912
X#define`09LBR$L_GH_CTLTBL`094
X#define`09LBR$L_GH_RETARY`098
X#define`09LBR$S_LBRDEF4`0912
X#define`09LBR$L_SI_CTLTBL`094
X#define`09LBR$L_SI_IDXNUM`098
X#define`09LBR$S_LBRDEF5`0916
X#define`09LBR$L_LK_CTLTBL`094
X#define`09LBR$L_LK_KEYNAM`098
X#define`09LBR$L_LK_TXTRFA`0912
X#define`09LBR$S_LBRDEF6`0916
X#define`09LBR$L_IK_CTLTBL`094
X#define`09LBR$L_IK_KEYNAM`098
X#define`09LBR$L_IK_TXTRFA`0912
X#define`09LBR$S_LBRDEF7`0920
X#define`09LBR$L_RK_CTLTBL`094
X#define`09LBR$L_RK_KEYNAM`098
X#define`09LBR$L_RK_OLDRFA`0912
X#define`09LBR$L_RK_NEWRFA`0916
X#define`09LBR$S_LBRDEF8`0912
X#define`09LBR$L_DK_CTLTBL`094
X#define`09LBR$L_DK_KEYNAM`098
X#define`09LBR$S_LBRDEF9`0912
X#define`09LBR$L_DD_CTLTBL`094
X#define`09LBR$L_DD_TXTRFA`098
X#define`09LBR$S_LBRDEF10`0916
X#define`09LBR$L_GR_CTLTBL`094
X#define`09LBR$L_GR_BUFDES`098
X#define`09LBR$L_GR_BUFLEN`0912
X#define`09LBR$S_LBRDEF11`0916
X#define`09LBR$L_PR_CTLTBL`094
X#define`09LBR$L_PR_BUFDES`098
X#define`09LBR$L_PR_TXTRFA`0912
X#define`09LBR$S_LBRDEF12`098
X#define`09LBR$L_PE_CTLTBL`094
X#define`09LBR$S_LBRDEF13`0920
X#define`09LBR$L_SR_CTLTBL`094
X#define`09LBR$L_SR_IDXNUM`098
X#define`09LBR$L_SR_RFA`0912
X#define`09LBR$L_SR_USRTN`0916
X#define`09LBR$S_LBRDEF14`0912
X#define`09LBR$L_SU_KEYDES`094
X#define`09LBR$L_SU_TXTRFA`098
X#define`09LBR$S_LBRDEF15`0916
X#define`09LBR$L_GI_CTLTBL`094
X#define`09LBR$L_GI_IDXNUM`098
X#define`09LBR$L_GI_USRTN`0912
X#define`09LBR$S_LBRDEF16`0912
X#define`09LBR$L_GU_KEYADR`094
X#define`09LBR$L_GU_TXTRFA`098
X#define`09LBR$C_ADDMOD`091
X#define`09LBR$C_DELMOD`092
X#define`09LBR$C_REPMOD`093
X#define`09LBR$S_LBRDEF17`0916
X#define`09LBR$L_AU_CTLTBL`094
X#define`09LBR$L_AU_FLAGS`098
X#define`09LBR$L_AU_KEYNAM`0912
X#define`09LBR$S_LBRDEF18`0912
X#define`09LBR$L_GU_CTLTBL`094
X#define`09LBR$L_GU_USRTN`098
X#define`09LBR$S_LBRDEF19`098
X#define`09LBR$L_UU_UPDESC`094
$ CALL UNPACK LBRDEF.H;1 796729746
$ create 'f'
X%!PS-Adobe-2.0 ExitServer
X%%Title: dmm-nup.ps
X%%Creator: DMM
X%%CreationDate: 04/25/92 13:28
X%%DocumentSuppliedProcSets: "dmm-nup" 3 0
X%
X% Written by Donald Markuson, Prime Computer, Inc., 1990-1992.
X% Placed into the public domain by the author September 1, 1991.
X% Comments and suggestions are welcome and may be addressed to
X% dmm@tiger1.prime.com.
X%
Xuserdict/dcheckload 2 copy known`7Bpop pop`7D`7B`7B`7Bpop exec`7D`7Bsave 3 d
Vict begin/rb 6050
Xstring def exch/es exch def`7Bcurrentfile rb readline not`7Bstop`7Dif es
Xeq`7Bexit`7Dif`7Dloop end restore pop`7Difelse`7Dbind put`7Difelse`7B`7D( %e
Vnddmmnupdict)`20
Xvmstatus pop pop 0 gt userdict/DMM-nup-pre known not or dcheckload
Xsystemdict/setpacking known`7Bcurrentpacking true setpacking`7Dif
Xuserdict/DMM-nup-pre`7Bsystemdict begin userdict begin/DMM-nup-dict 60 dict
V def
XDMM-nup-dict begin/T true def/F false def/xdf`7Bexch def`7Dbind def/endpage
Xxdf/startpage xdf/pbgray xdf/noclip xdf/flipit xdf/lscape xdf/xpose xdf/lps-
Vpp
Xxdf lps-pp 1 eq`7B/realshowpage/showpage load def userdict/showpage`7BDMM-nu
Vp-dict
Xbegin gsave grestore realshowpage end`7Dbind put/finish`7Buserdict
Xbegin/showpage/realshowpage load def end`7Dbind def end`7D`7Buserdict/DMM-nu
Vp-state
X10 dict dup begin put/pp-num 0 def/lp-num 0 def/pagecount 0 def/Pstate matri
Vx
Xdef/Lstate matrix def/oldLstate matrix def/Cstate matrix def/Tstate matrix
Xdef/ppstr 15 string def/did-showpage F def end/statusdict where`7Bpop
X`7D`7Buserdict/statusdict 1 dict put`7Difelse`7B/realinitclip/initclip load
V def
X/realinitmatrix/initmatrix load def/realinitgraphics/initgraphics load def
X/realshowpage/showpage load def/realrestore/restore load def/realgrestore
X/grestore load def/realgsave/gsave load def/realerasepage/erasepage load def
Xstatusdict/setpapertray 2 copy known`7Bget/realsetpapertray exch def`7D`7Bpo
Vp pop`7D
Xifelse/setpagedevice dup where`7Bexch get/realsetpagedevice xdf`7D`7Bpop`7D
Xifelse/currentpagedevice dup where`7Bexch get/realcurrentpagedevice xdf`7D`7
VBpop`7D
Xifelse`7Dexec userdict/initclip`7BDMM-nup-dict dup/realinitclip get exec/noc
Vlip get
Xnot`7Berrordict/nocurrentpoint get errordict/nocurrentpoint`7Bpop 0 0`7Dput
Xcurrentpoint errordict/nocurrentpoint 5 -1 roll put currentlinewidth
XDMM-nup-state/Tstate get currentmatrix DMM-nup-state/Pstate get setmatrix 0.
V3
Xsetlinewidth DMM-nup-state/Lstate get setmatrix newpath DMM-nup-dict/lp-wid
V get
XDMM-nup-dict/lp-hgt get 0 exch moveto dup 0 rlineto 0 lineto 0 0 lineto
Xclosepath clip newpath setmatrix setlinewidth moveto`7Dif`7Dbind put
Xuserdict/initmatrix`7BDMM-nup-state/Lstate get setmatrix`7Dbind put
Xuserdict/initgraphics`7BDMM-nup-dict/realinitgraphics get exec initmatrix
Xinitclip`7Dbind put userdict/erasepage`7BDMM-nup-dict/realgsave get exec ini
Vtclip 1
Xsetgray newpath clippath fill DMM-nup-dict/realgrestore get exec`7Dbind put
Xuserdict/showpage`7BDMM-nup-dict begin T lshowpage end`7Dbind put
Xuserdict/restore`7BDMM-nup-state/pp-num get exch DMM-nup-state/lp-num get ex
Vch
XDMM-nup-state /pagecount get exch
XDMM-nup-dict /realrestore get exec
XDMM-nup-state /pagecount 3 -1 roll put
XDMM-nup-state/lp-num 2 copy get 4 1 roll 2
Xindex put eq exch DMM-nup-state/pp-num 2 copy get 4 1 roll 2 index put eq an
Vd
Xnot`7BDMM-nup-dict begin F lshowpage end`7Dif`7Dbind put userdict/grestore
X`7BDMM-nup-dict/realgrestore get exec DMM-nup-state/did-showpage get
X`7BDMM-nup-state begin oldLstate Lstate copy pop end DMM-nup-dict begin F
Xlshowpage end`7Dif`7Dbind put userdict/gsave`7BDMM-nup-state/did-showpage fa
Vlse put
XDMM-nup-dict/realgsave get exec`7Dbind put`7B/setpagedevice where`7Bpop
Xuserdict/setpagedevice`7BDMM-nup-state begin pp-num 0 eq lp-num 0 eq and end
XDMM-nup-dict begin`7Brealsetpagedevice realinitgraphics setpaper ppdict begi
Vn
Xpp-w pp-h end true`7D`7Bdup/PageSize known dup`7Bexch/PageSize get aload pop
V 3 -1
Xroll`7Dif`7Difelse`7Bsetpage`7D`7Bpop`7Difelse end`7Dbind put`7Dif/currentpa
Vgedevice where`7Bpop
Xuserdict/currentpagedevice`7BDMM-nup-dict begin realcurrentpagedevice
Xdup/PageSize known`7Bdup length dict copy dup/PageSize `5Blp-wid lp-hgt`5D p
Vut
Xreadonly`7Dif end`7Dbind put`7Dif`7Dexec/finish`7BDMM-nup-state begin lp-num
V 0 gt
X`7Bemitppage`7Dif end userdict begin/initclip/realinitclip load
Xdef/initmatrix/realinitmatrix load def/initgraphics/realinitgraphics load
Xdef/showpage/realshowpage load def/restore/realrestore load
Xdef/grestore/realgrestore load def/gsave/realgsave load
Xdef/erasepage/realerasepage load def statusdict/setpapertray 2 copy known
X`7B/realsetpapertray load put`7D`7Bpop pop`7Difelse userdict/setpagedevice 2
V copy
Xknown`7B/realsetpagedevice load put`7D`7Bpop pop`7Difelse userdict/currentpa
Vgedevice 2
Xcopy known`7B/realcurrentpagedevice load put`7D`7Bpop pop`7Difelse end`7Dbin
Vd def
X/lshowpage`7BDMM-nup-state begin dup`7Bpagecount 1 add startpage lt`7Berasep
Vage`7Dif`7Dif
XTstate currentmatrix Lstate Cstate invertmatrix
XCstate concatmatrix pop dup/did-showpage xdf dup`7B
XLstate oldLstate copy pop /pagecount pagecount 1 add def pagecount startpage
V ge
X`7Bpagecount endpage eq `7Bemitppage (stop) = stop`7D
X`7Bpagecount endpage lt`7B/lp-num lp-num 1 add def
Xlp-num lps-pp eq `7Bemitppage`7Dif`7Dif`7Difelse`7Dif
XPstate setmatrix lporig initgraphics realgsave`7D
X`7BPstate setmatrix lporig initclip`7Difelse Cstate
Xconcat end fixnasties`7Brealgrestore`7Dif`7Dbind def`20
X/emitppage`7B/lp-num 0 def/pp-num pp-num 1 add def pbgray exec dup 0.0 ge ex
Vch
X1.0 le and`7Brealgsave Pstate setmatrix realinitclip`7B`7Dsettransfer pbgray
V exec
Xsetgray newpath 0.3 setlinewidth 0 1 lp-row`7Blp-hgt lp-scl mul mul 0 exch m
Voveto
Xlp-col lp-wid lp-scl mul mul 0 rlineto`7Dfor 0 1 lp-col`7Blp-wid lp-scl mul
V mul 0
Xmoveto 0 lp-row lp-hgt lp-scl mul mul rlineto`7Dfor stroke realgrestore`7Dif
Xrealshowpage`7Dbind def/lporig`7Blp-scl dup scale xpose lscape xor`7Blp-num
V lp-col
Xmod lp-wid mul lp-num lp-col idiv`7D`7Blp-num lp-row idiv lp-wid mul lp-num
V lp-row
Xmod`7Difelse lscape`7Blp-row 1 sub exch sub`7Dif 1 add neg lp-row add lp-hgt
V mul
Xtranslate Lstate currentmatrix pop`7Dbind def/fixnasties
X`7B`5B/TeXDict/TeXdict/TexDict/Texdict/texdict`5D`7Bdup where`7Bexch get dup
V/Mtrx known
X`7B/Mtrx get currentmatrix`7Dif`7Dif pop`7Dforall`7Dbind def/setlayout`7Bdup
V 16 gt exch 0
Xlt or`7B/lps-pp 1 def`7Dif `5B`7B`7D1 1 1 2 2 2 2 2 3 3 3 3 3 3 3 4`5D lps-p
Vp get exec `5B`7B`7D1
X2 3 2 3 3 4 4 3 4 4 4 5 5 5 4`5D lps-pp get exec ppdict begin/lp-col-orig
Xxdf/lp-row-orig xdf lps-pp 0 eq`7BDMM-nup-dict/lps-pp lp-row-orig lp-col-ori
Vg mul
Xput`7Dif end`7Dbind def/setpaper`7Bppdict begin newpath clippath pathbbox ne
Vwpath
Xpipp pp-w pp-h gt`7B0 pp-h translate -90 rotate pi-lly pi-llx pi-ury pi-urx
Xpipp`7Dif pp-matrix currentmatrix pop pbgray exec dup 0.0 ge exch 1.0 le
Xand`7B/pi-mar 12 def/pp-mar 36 def`7D`7B/pi-mar 0 def/pp-mar 36 def`7Difelse
V/li-llx
Xpi-llx pi-mar add def li-llx pp-mar lt`7B/li-llx pp-mar def`7Dif/li-lly pi-l
Vly
Xpi-mar add def li-lly pp-mar lt`7B/li-lly pp-mar def`7Dif/li-urx pi-urx pi-m
Var sub
Xdef li-urx pp-w pp-mar sub gt`7B/li-urx pp-w pp-mar sub def`7Dif/li-ury pi-u
Vry
Xpi-mar sub def li-ury pp-h pp-mar sub gt`7B/li-ury pp-h pp-mar sub def`7Dif/
Vli-w
Xli-urx li-llx sub def/li-h li-ury li-lly sub def end/lp-wid -1 def/lp-hgt -1
Xdef`7Dbind def/setpage`7Bppdict begin/lp-h xdf/lp-w xdf lp-h -1 eq lp-w -1 e
Vq
Xand`7Bsave exch realinitgraphics statusdict/papertray get exec exch
Xrealsetpapertray newpath clippath pathbbox 6 -2 roll realsetpapertray
Xrealrestore 3 -1 roll add/lp-h xdf add/lp-w xdf`7Dif lp-w lp-wid sub abs 5.0
V gt
Xlp-h lp-hgt sub abs 5.0 gt or end`7BDMM-nup-state begin lp-num 0 gt`7Bemitpp
Vage`7Dif
Xend ppdict begin lp-row-orig lp-col-orig lp-w lp-h gt end`7B/lp-row xdf/lp-c
Vol
Xxdf`7D`7B/lp-col xdf/lp-row xdf`7Difelse ppdict begin DMM-nup-dict/portpp lp
V-w lp-col
Xmul lp-h lp-row mul le put/ll-w/ll-h portpp`7Bexch`7Dif lp-w lp-col mul def
V lp-h
Xlp-row mul def DMM-nup-dict/lp-scl li-h ll-h div li-w ll-w div 2 copy
Xgt`7Bexch`7Dif pop put pp-matrix setmatrix portpp not lscape and`7Bpp-w pp-h
Xtranslate 180 rotate`7Dif li-w ll-w lp-scl mul sub 2 div li-llx add li-h ll-
Vh
Xlp-scl mul sub 2 div li-lly add translate portpp not`7Bll-w lp-scl mul 0
Xtranslate 90 rotate`7Dif DMM-nup-dict/lp-wid lp-w put DMM-nup-dict/lp-hgt lp
V-h
Xput end  DMM-nup-state begin Pstate currentmatrix pop lporig initclip
Xflipit`7Blp-wid lp-hgt translate 180 rotate`7Dif end`7Dif`7Dbind def`7B/ppdi
Vct 30 dict
Xdef ppdict begin/pp-matrix matrix def/pipp`7B/pi-ury xdf/pi-urx xdf/pi-lly
Xxdf/pi-llx xdf/pp-w pi-urx pi-llx add def/pp-h pi-ury pi-lly add def`7Dbind
V def
Xend lps-pp setlayout setpaper ppdict begin pp-w pp-h end setpage`7Dexec end
V 8
Xdict begin`7B/in`7B72 mul`7Dbind def/mm`7B72 25.4 div mul`7Dbind def/str 40
V string def
X/fixuptray`7Bexch str cvs length dup str exch (tray) putinterval 4 add str e
Vxch 0
Xexch getinterval cvn statusdict 1 index known`7Bstatusdict exch `5B`7BDMM-nu
Vp-state
Xbegin pp-num 0 eq lp-num 0 eq and end DMM-nup-dict begin`7D/exec load
X`5B/-realtray-`7Bexec realinitgraphics setpaper ppdict begin pp-w pp-h end`7
VD/exec
Xload`5D cvx `5B/-w-/-h-`5D cvx`7Bifelse setpage end`7D/exec load `5D dup 2 g
Vet 0 4 index 4
Xindex get put dup 3 get 0 6 -1 roll putinterval cvx put`7D`7Bpop pop`7Difels
Ve`7Dbind
Xdef/putalways`7B2 copy userdict 3 1 roll `5B`7BDMM-nup-dict begin`7D/exec lo
Vad/-w-
X/-h-`7Bsetpage end`7D/exec load`5D dup 2 4 -1 roll putinterval cvx put fixup
Vtray`7Dbind
Xdef/putneeded`7B1 index where`7Bpop putalways`7D`7Bpop pop`7Difelse`7Dbind
Xdef`7Dexec`7B/setpaper `5B-1 -1`5D fixuptray/letter `5B8.5 in 11 in`5D putal
Vways/legal
X`5B8.5 in 14 in`5D putalways/executivepaper `5B7.25 in 10.5 in`5D putneeded/
V11x17 `5B11
Xin 17 in`5D putalways/ledger `5B11 in 17 in`5D putneeded`7Dexec`7B/a0 `5B841
V mm 1189 mm`5D
Xputneeded/a1 `5B594 mm 841 mm`5D putneeded/a2 `5B420 mm 594 mm`5D putneeded/
Va3 `5B297 mm
X420 mm `5D putalways/a4 `5B210 mm 297 mm`5D putalways/a5 `5B148 mm 210 mm`5D
V putneeded/a6
X`5B105 mm 148 mm`5D putneeded/a7 `5B74 mm 105 mm`5D putneeded/a8 `5B52 mm 74
V mm`5D
Xputneeded/a9 `5B37 mm 52 mm`5D putneeded/a10 `5B26 mm 37 mm`5D putneeded`7De
Vxec`7B/b0
X`5B1000 mm 1414 mm`5D putneeded/b1 `5B707 mm 1000 mm`5D putneeded/b2 `5B500
V mm 707 mm`5D
Xputneeded/b3 `5B353 mm 500 mm`5D putneeded/b4 `5B250 mm 353 mm`5D putneeded/
Vb5 `5B176 mm
X250 mm`5D putalways/b6 `5B125 mm 176 mm`5D putneeded/b7 `5B88 mm 125 mm`5D p
Vutneeded/b8
X`5B62 mm 88 mm`5D putneeded/b9 `5B44 mm 62 mm`5D putneeded/b10 `5B31 mm 44 m
Vm`5D
Xputneeded`7Dexec`7B/c0 `5B914.4 mm 1300.5 mm`5D putneeded/c1 `5B650.2 mm 914
V.4 mm`5D
Xputneeded/c2 `5B457.2 mm 650.2 mm`5D putneeded/c3 `5B325.1 mm 457.2 mm`5D pu
Vtneeded/c4
X`5B228.6 mm 325.1 mm`5D putneeded/c5 `5B162.6 mm 228.6 mm`5D putneeded/c6 `5
VB114.3 mm
X162.6 mm`5D putneeded/c7 `5B81.3 mm 114.3 mm`5D putneeded`7Dexec
Xend`7B/lettersmall/letter load def/note/letter load def/a4small/a4 load def
Xstatusdict/setpage known`7Bstatusdict/setpage`7Bpop DMM-nup-dict begin setpa
Vge
Xend`7Dbind put`7Dif statusdict/setpageparams known`7Bstatusdict/setpageparam
Vs`7Bpop
Xpop DMM-nup-dict begin setpage end`7Dbind put`7Dif`7Dexec`7Difelse end end`7
VDput
Xuserdict/DMM-nup-post`7BDMM-nup-dict begin finish end`7Dbind put
Xsystemdict/setpacking known`7Bsetpacking`7Dif
$ CALL UNPACK NUMBER_UP.PS;10 1025215607
$ create 'f'
X%%%`09paint - puts a MacPaint compressed raster file on the laser printer.
X%
X%
X%`09inputs:`09/nc /ncopies /params - number of copies (default 1)
X%`09`09/sf /scale /param2 - scale factor (default 4.0)
X%
X%`0902/18/87 R. Watson Added parser stuff. Speedup mods.
X%
X
X%%`09deCompress <string>.
X%
X%`09returns a bitimage string on the stack
X%
X/deCompress
X`7B
X`09/count getByte byte def`09`09`09% get count
X`09/ind 0 def`09`09`09`09% preset index
X`09count 16#80 and 0 eq `7B`09`09`09% if bit stream
X`09`09/count count 1 add def
X`09`09outstring 0 count getinterval   % get right size string
X`09`09inp exch readhexstring`09`09% get bytes
X`09`09pop`09`09`09`09% toss readhexstring status
X`09`7D
X`09`7B`09`09`09`09`09% else repeated string
X`09`09getByte`09`09`09`09% get byte to repeat
X`09`0916#100 count sub 1 add /count exch def% get abs val of count
X`09`09count `7B
X`09`09`09outstring ind byte put
X`09`09`09/ind ind 1 add def`09`09% advance index
X`09`09`7D repeat
X`09`09outstring 0 count getinterval`09% return string
X`09`7D ifelse
X`7D def
X
X
X%%`09getByte
X%
X%`09returns /byte = next input byte
X%`09`09      = 0 if no more bytes on input stream
X%
X/getByte
X`7B
X`09inp instring readhexstring `7B`09`09% if got one
X`09`090 get /byte exch def`09`09% store in byte
X`09`7D
X`09`7B`09`09`09`09`09% else 0
X`09`09pop /byte 0 def
X`09`7D ifelse
X`7D def
X
X
X%%`09main program
X%
X/main
X`7B
X`09/sTime usertime def`09`09`09% save start time
X%%%     vmstatus 10 20 string cvrs dbg exch writestring dbg ( ) writestring
X%%%              10 20 string cvrs dbg exch writestring dbg ( ) writestring
X%%%              10 20 string cvrs dbg exch writestring dbg ( \n) writestrin
Vg
X%%%      flush
X`09/iscale 1 scale div def`09`09`09% compute scale factor
X`09512 `7B getByte`7D repeat`09`09`09% eat paint header
X%`09576 720 1 `5Biscale 0.0 0.0 iscale 0.0 0.0`5D `7B deCompress `7D image
X`09576 720 true `5Biscale 0.0 0.0 iscale 0.0 0.0`5D `7BdeCompress`7D imagema
Vsk
X%%%`09usertime sTime sub 1000 div 10 20 string cvrs
X%%%`09 dbg exch writestring dbg ( seconds )
X%%%`09 writestring
X%%%    vmstatus 10 20 string cvrs dbg exch writestring dbg ( ) writestring
X%%%            10 20 string cvrs dbg exch writestring dbg ( ) writestring
X%%%              10 20 string cvrs dbg exch writestring dbg ( \n) writestrin
Vg
X%%%      flush
X`09showpage
X`09currentfile flushfile`09`09`09% avoid laser_log's
X`7D def
X
X
X%%`09executable initialization
X%
X/inp (%stdin) (r) file def`09`09% define files
X/dbg (%stdout) (w) file def
X
X/table `5B
X `5B/#copies 1 (.nc .ncopies .param1)`5D`09`09% number of copies
X `5B/scale 4.0 (.sf .scale .param2)`5D`09`09% scale factor
X`5D def
X
Xtable `7B`09`09`09`09`09`09% apply defaults
X`09/ta exch def`09`09`09`09% save array
X`09ta 0 get`09`09`09`09% key
X`09ta 1 get`09`09`09`09% default value
X`09def`09`09`09`09`09% define default value
X`7D forall
X
Xcurrentdict /parser known `7Bparser`7D if`09`09% if user inputs
X
X/identity matrix def`09`09`09% make an identity matrix
X/outstring 128 string def`09`09% storage for output string
X/instring 1 string def`09`09`09% input buffer
X1 72 mul 10 72 mul moveto currentpoint translate
Xcurrentpoint transform`09`09`09% see where we are in device coords
Xidentity setmatrix`09`09`09% turn off transformation - switch to
X`09`09`09`09`09%  device coordinate system
Xtranslate`09`09`09`09% move origin to transformed currpt
X
X/doit `7B
X`09`7Bmain`7D stopped `7B (error stack:\n) = pstack flush quit`7D if
X`7D def
X%doit
Xmain
$ CALL UNPACK PAINT_HEX.PS;1 1244988067
$ create 'f'
X%  Parser takes 2 arguments as input:
X%  /params is an array of pairs of keyword strings and values:
X%  `5B (param1) value1 (param2) value2 ... (paramn) valuen`5D
X%  /table is an array of key/default value/keyword list arrays:
X%  `5B `5B/key1 default1 (.key1 .whatever1)`5D
X%    `5B/key2 default2 (.key2 .whatever2)`5D
X%    ... `5D
X%  Parser first defines /key1 to default1, /key2 to default2, etc.
X%  Then, for each param keyword in /params, it searches the arrays
X%  in /table for a matching keyword.  If found, it sets /key? to`20
X%  the value from /params.
X
X/parser `7B
X
X% process each keyword value pair in the params array
X
X`09/pindex 0 def`09`09`09`09`09% preset index
X`09`09params length 2 idiv `7B
X`09`09params pindex get length 1 add`09`09% build keyword str
X`09`09`09string /ks exch def
X`09`09ks 1 params pindex get putinterval`09% (.<keyword>)
X`09`09ks 0 46 put
X`09`09/ok false def`09`09`09`09% preset flag
X`09`09table `7B`09`09`09`09`09% for each array
X`09`09`09/ta exch def`09`09`09% get the array
X`09`09`09`09ta 2 get`09`09% get token string
X`09`09`09`09ks search `7B`09`09% search for keyword
X`09`09`09`09`09pop pop pop`09% flush search stuff
X`09`09`09`09`09ta 0 get `09% get key
X`09`09`09`09`09params pindex 1 add get % get new value
X`09`09`09`09`09def`09`09% set new value
+-+-+-+-+-+-+-+-  END  OF PART 4 +-+-+-+-+-+-+-+-