From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX"  1-SEP-1989 13:42
To:	MRGATE::"ARISIA::EVERHART"
Subj:	Apple LaserWriter Symbiont (1 of 12)

Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Fri,  1 SEP 89 07:17:45 PDT
Received: from ecsgate.uncecs.edu by KL.SRI.COM with TCP; Fri, 1 Sep 89 06:57:13 PDT
Received: by ecsgate.uncecs.edu (5.59/UNCECS/8-30-88)
	id AA22501; Fri, 1 Sep 89 09:57:15 EDT
Message-Id: <8909011357.AA22501@ecsgate.uncecs.edu>
Date: Fri, 1 Sep 89 09:54 EDT
From: "Bill Bailey, 'The VAXman'" <BAILEYB@ATSUVAX1.BITNET>
Subject: Apple LaserWriter Symbiont (1 of 12)
To: INFO-VAX@KL.SRI.COM
X-Vms-To: INFOVAX

$! ------------------ CUT HERE -----------------------
$ v='f$verify(f$trnlnm("SHARE_VERIFY"))'
$!
$! This archive created by VMS_SHARE Version 7.1-004  3-AUG-1989
$!   On 31-AUG-1989 10:49:41.52   By user WILTS (Ed Wilts)
$!
$! This VMS_SHARE Written by:
$!    Andy Harper, Kings College London UK
$!
$! Acknowledgements to:
$!    James Gray       - Original VMS_SHARE
$!    Michael Bednarek - Original Concept and implementation
$!
$!+ THIS PACKAGE DISTRIBUTED IN 12 PARTS, TO KEEP EACH PART
$!  BELOW 30 BLOCKS
$!
$! TO UNPACK THIS SHARE FILE, CONCATENATE ALL PARTS IN ORDER
$! AND EXECUTE AS A COMMAND PROCEDURE  (  @name  )
$!
$! THE FOLLOWING FILE(S) WILL BE CREATED AFTER UNPACKING:
$!       1. [.LASER_DIST]AAAREADME.DOC;1
$!       2. [.LASER_DIST]BITIMAGE_HEX.PS;1
$!       3. [.LASER_DIST]HEADERS_STR.PS;1
$!       4. [.LASER_DIST]IMAGE_HEX.PS;1
$!       5. [.LASER_DIST]LASER.C;1
$!       6. [.LASER_DIST]LASER.HLP;1
$!       7. [.LASER_DIST]LASER.OPT;1
$!       8. [.LASER_DIST]LASER_ERR.MSG;1
$!       9. [.LASER_DIST]LBRDEF.H;1
$!      10. [.LASER_DIST]PAINT_HEX.PS;1
$!      11. [.LASER_DIST]PARSER.PS;1
$!      12. [.LASER_DIST]PATCH.PS;1
$!      13. [.LASER_DIST]PS.PS;1
$!      14. [.LASER_DIST]QUIDEF.H;1
$!      15. [.LASER_DIST]SMBDEF.H;1
$!      16. [.LASER_DIST]SYST.COM;2
$!      17. [.LASER_DIST]TRAILER.PS;1
$!      18. [.LASER_DIST]ZETA.PS;1
$!
$set="set"
$set symbol/scope=(nolocal,noglobal)
$f=f$parse("SHARE_TEMP","SYS$SCRATCH:.TMP_"+f$getjpi("","PID"))
$e="write sys$error  ""%UNPACK"", "
$w="write sys$output ""%UNPACK"", "
$ if f$trnlnm("SHARE_LOG") then $ w = "!"
$ if f$getsyi("version") .ges. "V4.4" then $ goto START
$ e "-E-OLDVER, Must run at least VMS 4.4"
$ v=f$verify(v)
$ exit 44
$UNPACK: SUBROUTINE ! P1=filename, P2=checksum
$ if f$search(P1) .eqs. "" then $ goto file_absent
$ e "-W-EXISTS, File ''P1' exists. Skipped."
$ delete/nolog 'f'*
$ exit
$file_absent:
$ if f$parse(P1) .nes. "" then $ goto dirok
$ dn=f$parse(P1,,,"DIRECTORY")
$ w "-I-CREDIR, Creating directory ''dn'."
$ create/dir 'dn'
$ if $status then $ goto dirok
$ e "-E-CREDIRFAIL, Unable to create ''dn'. File skipped."
$ delete/nolog 'f'*
$ exit
$dirok:
$ w "-I-PROCESS, Processing file ''P1'."
$ define/user sys$output nl:
$ EDIT/TPU/NOSEC/NODIS/COM=SYS$INPUT 'f'/OUT='P1'
PROCEDURE Unpacker ON_ERROR ENDON_ERROR;SET(FACILITY_NAME,"UNPACK");SET(
SUCCESS,OFF);SET(INFORMATIONAL,OFF);f:=GET_INFO(COMMAND_LINE,"file_name");
buff:=CREATE_BUFFER(f,f);p:=SPAN(" ")@r&LINE_END;POSITION(BEGINNING_OF(buff))
;LOOP EXITIF SEARCH(p,FORWARD)=0;POSITION(r);ERASE(r);ENDLOOP;POSITION(
BEGINNING_OF(buff));g:=0;LOOP EXITIF MARK(NONE)=END_OF(buff);x:=
ERASE_CHARACTER(1);IF g = 0 THEN IF x="X" THEN MOVE_VERTICAL(1);ENDIF;IF x=
"V" THEN APPEND_LINE;MOVE_HORIZONTAL(-CURRENT_OFFSET);MOVE_VERTICAL(1);ENDIF;
IF x="+" THEN g:=1;ERASE_LINE;ENDIF;ELSE IF x="-" THEN g:=0;ENDIF;ERASE_LINE;
ENDIF;ENDLOOP;p:="`";POSITION(BEGINNING_OF(buff));LOOP r:=SEARCH(p,FORWARD);
EXITIF r=0;POSITION(r);ERASE(r);COPY_TEXT(ASCII(INT(ERASE_CHARACTER(3))));
ENDLOOP;o:=GET_INFO(COMMAND_LINE,"output_file");WRITE_FILE(buff,o);
ENDPROCEDURE;Unpacker;EXIT;
$ delete/nolog 'f'*
$ CHECKSUM 'P1'
$ IF CHECKSUM$CHECKSUM .eqs. P2 THEN $ EXIT
$ e "-E-CHKSMFAIL, Checksum of ''P1' failed."
$ ENDSUBROUTINE
$START:
$ create/nolog 'f'
XLASER is a user-written print symbiont that is tailored specifically to the
XApple LaserWriter family and other PostScript printers.
X
XThe symbiont as distributed is configured to print normal text files in
Xa variety of formats on the laser printer.  Support is also included for
Xprinting PostScript files, MacPaint files, and Zeta plot files.  See
XLASER.C for additional capabilities of the symbiont.
X
XThis distribution consists of the following files:
X
XFile`009`009Destination`009`009Purpose
X---------------------------------------------------------------------------
XAAAREADME.DOC`009`009`009`009This file
XLASER.EXE`009SYS$SYSTEM:LASER.EXE`009The symbiont executable.
X*.PS`009`009SYS$LIBRARY:LASER.TLB`009Library of PostScript header files.
XLASER.C`009`009`009`009`009Symbiont sources.
XLASER_ERR.MSG`009`009`009`009Error message source.
XQUIDEF.H`009`009`009`009Source header files.
XSMBDEF.H
XLBRDEF.H
XLASER.OPT`009`009`009`009Link options file.
XLASER.HLP`009SYS$HELP:HELPLIB.HLB`009Description of forms supported.
XSYST.COM`009SYS$MANAGER:SYSTARTUP.COM Queue startup commands.
X
XInstallation.
X
XInstallation of the files can be accomplished with the following set of
Xcommands:
X
X$ LIBRARY/CREATE/TEXT LASER *.PS
X$ COPY LASER.EXE SYS$SYSTEM:/PROT=W:RE
X$ COPY LASER.TLB SYS$LIBRARY:/PROT=W:RE
X$ LIBRARY /HELP SYS$HELP:HELPLIB LASER`009`009! Optional
X
XSelect a terminal port to attach the printer to, and edit SYST.COM to
Xreflect your change.  SYST.COM may be invoked by your system startup
Xprocedures.  The printer may be connected with a cable that has only
Xtransmit, receive and ground pins connected.  Transmit and receive
Xshould (I think) be swapped. The switch on the LaserWriter should be
Xswitched to the "9600" position.  If you are sharing your LaserWriter
Xwith a Macintosh connected via AppleTalk, use the following procedure
Xwhen switching the printer:
X
XTo switch the printer to the VAX:
X1. Insure that no AppleTalk jobs are in progress.
X2. Disconnect the appletalk connector from the laserwriter.
X3. Switch switch on LaserWriter to "9600".
X4. $START/QUEUE ALW
X
XTo switch the printer to the MAC:
X1. $STOP/QUEUE/NEXT ALW
X2. Allow any jobs in progress to complete.
X3. Switch switch on LaserWriter to "AppleTalk".
X4. Connect the appletalk connector to the laserwriter.
X
X$ CREATE SYS$SYSDEVICE:`091LASER`093.  This area is used for LASER log files
Xfor spooled files, or when the laser log cannot be created in the user's
Xdirectory.  The location and name of the directory may be changed by`032
Xchanging the definition for LASER$LOG in SYST.COM.  Log files are only
Xcreated when there is an error in the job, or when the job sends back
Xinformation (i.e. using the PostScript PRINT command).
X
XTo build the symbiont from the sources:
X
X$ CC LASER
X$ MESSAGE LASER_ERR
X$ LINK LASER.OPT/OPT
X
XPostScript is a trademark of Adobe Inc.
XLaserWriter and MacPaint are trademarks of Apple Computer.
$ CALL UNPACK [.LASER_DIST]AAAREADME.DOC;1 1896228271
$ create/nolog 'f'
X%%%`009bitimage - puts an uncompressed hex bitmap on the page
X%
X%`009R. Watson
X%`00905-Feb-1987
X%
X%`009inputs:`009/param1 /ncopies /nc - number of copies (default 1)
X%`009`009/param2 /scale - scale factor to multiply by (default 1.0)
X%`009`009/param3 /xsize - x size in pixels (default 512)
X%`009`009/param4 /ysize - y size in pixels (default 512)
X%`009`009/param5 /pxlwid - number of bits in a pixel (1,2,4,8)
X%
X
X%%`009main program
X%
X/main
X`123
X`009/iscale 1 scale div def`009`009% compute scale factor
X%
X% get the image, fill black if run out of data. Note that readhexstring
X% returns false if we don't fill the string, so the input data should
X% be a multiple of sizeof(tmp) bytes long. Assume that it is more`032
X% efficient to read more than 1 byte at a time.  Note that line boundaries
X% do not matter.
X%
X`009xsize ysize pxlwid `091iscale 0.0 0.0  iscale 0.0 0.0`093
X`009`009`123 currentfile tmp readhexstring not `123pop <00>`125 if `125 imag
Ve
X
X`009showpage
X`009currentfile flushfile`009`009`009% avoid laser_log's
X`125 def
X
X
X%%`009executable initialization
X%
X/table `091
X `091/#copies 1 (.nc .ncopies .param1)`093`009`009% number of copies
X `091/scale 1.0 (.sf .scale .param2)`093`009`009% scale factor
X `091/xsize 512 (.xsize .param3)`093`009`009`009% x size
X `091/ysize 512 (.ysize .param4)`093`009`009`009% y size
X `091/pxlwid 1 (.pxlwid .param5)`093`009`009`009% pixel width
X`093 def
X
Xtable `123`009`009`009`009`009`009% apply defaults
X`009/ta exch def`009`009`009`009% save array
X`009ta 0 get`009`009`009`009% key
X`009ta 1 get`009`009`009`009% default value
X`009def`009`009`009`009`009% define default value
X`125 forall
X
Xcurrentdict /parser known `123parser`125 if`009`009% if user inputs
X
X/identity matrix def`009`009`009% make an identity matrix
X/tmp 8 string def
X1 72 mul 10 72 mul moveto currentpoint translate
Xcurrentpoint transform`009`009`009% see where we are in device coords
Xidentity setmatrix`009`009`009% turn off transformation - switch to
X`009`009`009`009`009%  device coordinate system
Xtranslate`009`009`009`009% move origin to transformed currpt
X
Xmain
$ CALL UNPACK [.LASER_DIST]BITIMAGE_HEX.PS;1 1514953140
$ create/nolog 'f'
X%%`009headers_str - print text with headers on LaserWriter
X%
X%`009R. Watson 25-Sep-1986
X%
X%`00910/03/86 RW Remove "_DUA0:`091`093" from filename (for spooled files)
X%`00910/25/87 RW Created from "headers.ps".  Uses explicit operators
X%`009`009    XSTR, XLF, XCR to gain more page control.
X%`00905/12/88 S. Roseman  Change XSTR to update xpos, and XCR to reset
X%`009`009    it to the left margin.  This allows multiple XSTRs to`032
X%`009`009    create 1 physical line.
X%`00906/14/88 RW Add xmargin to fix above mod.
X%
X%`009inputs:`009/param1 or /#copies - number of copies (default 1)
X%`009`009/param2 or /fsize = number containing font size
X%`009`009/param3 or /wide = boolean true if landscape mode
X%`009`009/param4 or /filename = string containing page header info
X%
X/EOF
X`123
X`009linecount 0 ne column 0 ne or `123`009% if we've printed a line
X`009`009/column ncolumns def`009% force page out
X`009`009newpage
X`009`125 if
X`125 def
X`032
X/XCR`032
X`123
X`009/xpos xmargin def`009%%%was leftmargin
X`125 def
X`032
X/XLF `123newline`125 def
X`032
X/XFF
X`123
X`009topmargin lineh sub ypos ne `123`009% if not top of page
X`009`009newpage
X`009`125 if
X`125 def
X`032
X`032
X%%`009<string> XSTR
X%
X%`009prints a line of text from the stack
X%
X/XSTR
X`123
X`009/line exch def`009`009`009`009% get text
X`032
X`009line length 1 ge `123`009`009`009%  show the line
X`009`009xpos ypos moveto
X`009`009squish 0 line ashow
X`009`009/xpos currentpoint pop def`009% save current x position
X`009`125 if
X`125 def
X`032
X`032
X%%`009newline - move down 1 line.
X%
X/newline `123
X`009/linecount linecount 1 add def`009% advance line count
X`009ypos lineh sub /ypos exch def`009% debit y pos on page
X`009ypos bottommargin lt`032
X`009 linecount linelimit gt or `123`009% if bottom of page
X`009`009newpage
X`009`009newline
X`009`125 if
X`125 def
X`032
X`032
X%%`009newpage - initialize for a new page.
X%
X/newpage `123
X`009/linecount 0 def`009`009`009% reset line count
X`009/ypos topmargin lineh sub def`009`009% reset line on page
X`032
X`009/column column 1 add def`009`009% advance column
X`009column ncolumns lt `123`009`009`009% if not last column
X`009`009/xmargin columnwidth column mul leftmargin add def
X`009`009/xpos xmargin def
X`009`125 `123
X`009`009/column 0 def`009`009`009% reset column
X`032
X`009`009title `123`009`009`009`009`009% if title
X`009`009`009leftmargin`032
X`009`009`009  topmargin titlemargin add moveto % setup header
X`009`009`009currentfont`009`009`009% save current font
X`009`009`009/Helvetica-Bold findfont 12 scalefont setfont
X`009`009`009filename show
X`009`009`009pagewidth 1.5 inch sub`032
X`009`009`009  topmargin titlemargin add moveto % page number
X`009`009`009(page ) show
X`009`009`009page 10 5 string cvrs show
X`009`009`009setfont`009`009`009`009% restore font
X`009`009`125 if`009`009
X`032
X`009`009showpage
X`009`009landscape
X`032
X`009`009page`009`009`009`009`009% save this
X`009`009saveobj restore `009`009`009% flush vm
X`009`009/saveobj save def
X`009`009/page exch def`009`009`009`009% restore this
X`032
X`009`009/page page 1 add def`009`009`009% advance page number
X`009`009/xmargin leftmargin def`009`009`009% reset left side
X`009`009/xpos xmargin def
X`009`125 ifelse
X`125 def`009
X`032
X`032
X%%`009landscape - set landscape mode
X%
X/landscape `123
X`009wide `123
X`009`0098.5 inch 0 translate 90 rotate
X`009`125 if
X`125 def
X`032
X%%`009<ivalue> inch <value>.
X%
X%`009convert <ivalue> to inches
X%
X/inch `123 72. mul`125 def
X`032
X`032
X%%`009<ivalue> point <value>.
X%
X%`009convert <ivalue> to points
X%
X/point `123 `125 def
X`032
X`032
X%%`009executable initialization.
X%
Xinitgraphics
X`032
Xcurrentdict /formname known not `123/formname (2UP) def`125 if
X`032
Xformname (2UP) eq `123
X`009/table `091
X`009 `091/#copies 1 (.nc .ncopies .param1)`093`009`009% number of copies
X`009 `091/fsizetmp 0 (.fsize .fs .param2)`093`009`009% font size
X`009 `091/wide true (.wide .w .param3)`093`009`009% landscape mode
X`009 `091/title false (.title .param4)`093 `009`009% title
X`009 `091/ncolumns 2 (.ncolumns .param5)`093`009`009% number of columns
X`009 `091/linelimit 66 (.linelimit .nlines .param6)`093`009% lines per page
X         `091/hdr () (.hdr .header. param7)`093`009`009% page header
X`009`093 def
X`125 if
X`032
Xformname (LETTER) eq `123
X`009/table `091
X`009 `091/#copies 1 (.nc .ncopies .param1)`093`009`009% number of copies
X`009 `091/fsizetmp 0 (.fsize .fs .param2)`093`009`009% font size
X`009 `091/wide false (.wide .w .param3)`093`009`009% landscape mode
X`009 `091/title false (.title .param4)`093 `009`009% title
X`009 `091/ncolumns 1 (.ncolumns .param5)`093`009`009% number of columns
X`009 `091/linelimit 66 (.linelimit .nlines .param6)`093`009% lines per page
X         `091/hdr () (.hdr .header. param7)`093`009`009% page header
X`009`093 def
X`125 if
X`032
Xformname (LANDSCAPE) eq `123
X`009/table `091
X`009 `091/#copies 1 (.nc .ncopies .param1)`093`009`009% number of copies
X`009 `091/fsizetmp 0 (.fsize .fs .param2)`093`009`009% font size
X`009 `091/wide true (.wide .w .param3)`093`009`009% landscape mode
X`009 `091/title false (.title .param4)`093 `009`009% title
X`009 `091/ncolumns 1 (.ncolumns .param5)`093`009`009% number of columns
X`009 `091/linelimit 66 (.linelimit .nlines .param6)`093`009% lines per page
X         `091/hdr () (.hdr .header. param7)`093`009`009% page header
X`009`093 def
X`125 if
X`032
Xformname (HEADERS) eq `123
X`009/table `091
X`009 `091/#copies 1 (.nc .ncopies .param1)`093`009`009% number of copies
X`009 `091/fsizetmp 0 (.fsize .fs .param2)`093`009`009% font size
X`009 `091/wide false (.wide .w .param3)`093`009`009% landscape mode
X`009 `091/title true (.title .param4)`093 `009`009% title
X`009 `091/ncolumns 1 (.ncolumns .param5)`093`009`009% number of columns
+-+-+-+-+-+-+-+-  END  OF PART 1 +-+-+-+-+-+-+-+-

