(FILECREATED "16-Apr-84 15:26:23" {ROSEBOWL}<BARRERA>FXPRINTER.;14 16279 changes to: (VARS FXPRINTERCOMS) (FNS FXPRINT \PRINTER.INIT) previous date: " 9-Apr-84 16:15:52" {ROSEBOWL}<BARRERA>FXPRINTER.;13) (* Copyright (c) 1984 by Xerox Corporation) (PRETTYCOMPRINT FXPRINTERCOMS) (RPAQQ FXPRINTERCOMS ((FILES (SYSLOAD FROM VALUEOF LISPUSERSDIRECTORIES) RS232) [ADDVARS [PRINTERTYPES ((FX.80 LOCALPRINTER) (CANPRINT (TEXT BITMAP WINDOW)) (STATUS TRUE) (PROPERTIES NILL) (SEND FXPRINT) (BITMAPSCALE NIL) (BITMAPFILE (FX.PRESSBITMAP FILE BITMAP SCALEFACTOR REGION ROTATION TITLE] (PRINTFILETYPES (TEXT (TEST TEXTFILEP) (EXTENSION (TEXT] (P (PUTPROP 'FX.80 'PRINTERTYPE 'LOCALPRINTER)) (FNS * PRINTERFNS) (VARS (DEFAULTLOCALBAUDRATE NIL) (SUPPRESS.PAPER.SET.FLAG NIL)))) (FILESLOAD (SYSLOAD FROM VALUEOF LISPUSERSDIRECTORIES) RS232) (ADDTOVAR PRINTERTYPES ((FX.80 LOCALPRINTER) (CANPRINT (TEXT BITMAP WINDOW)) (STATUS TRUE) (PROPERTIES NILL) (SEND FXPRINT) (BITMAPSCALE NIL) (BITMAPFILE (FX.PRESSBITMAP FILE BITMAP SCALEFACTOR REGION ROTATION TITLE)))) (ADDTOVAR PRINTFILETYPES (TEXT (TEST TEXTFILEP) (EXTENSION (TEXT)))) (PUTPROP 'FX.80 'PRINTERTYPE 'LOCALPRINTER) (RPAQQ PRINTERFNS (RS232.PRINT RS232.PRINTFILE FBITMAP FX.PRESSBITMAP FXPRINT BITMAPDISPLAY TEXTFILEP WINDOWDISPLAY WINDOW.TO.BITMAP BOLD.MODE COMMENT.MODE EXPANDED.MODE GRAPHICS.MODE SELECT.MODE STANDARD.MODE \PRINTER.COMMAND \PRINTER.CRLF \PRINTER.HEADING \PRINTER.INIT \PRINTER.MODE \PRINTER.PRINT.HEADING \PRINTER.TEXTINIT)) (DEFINEQ (RS232.PRINT [LAMBDA (FILENAME NOROTATE? STANDARD.SETUP) (* JBleier "17-Feb-84 16:07") (COND (STANDARD.SETUP (RS232INIT 9600 8 NIL 1 'DTR) (SETQ RS232XON\XOFF? T)) (T (\PRINTER.INIT))) (COND ((BITMAPP FILENAME) (FBITMAP FILENAME NOROTATE?)) ((WINDOWP FILENAME) (WINDOWDISPLAY FILENAME NOROTATE?)) (T (RS232.PRINTFILE FILENAME]) (RS232.PRINTFILE [LAMBDA (FILENAME) (* JBleier "20-Jan-84 18:16") (* This function takes a file, opens it for stream input (in the function \PRINTER.FILEINIT), and prints that file on an Epson FX-80 Printer. A later version of this function will allow user interaction such that, if the user owns a printer other than the Epson, he/she will be able to specify the command characters that allow certain font and mode changes on her/his particular printer. NOTE: check the documentation for this program for the correct pin connections for you particular machine.) (PROG (FILE) (\PRINTER.TEXTINIT) (* This function initializes print modes and form feeds on the Epson printer.) (\PRINTER.PRINT.HEADING FILENAME) (* The function \PRINTER.PRINT.HEADING sets up the mode for printing the heading, and calls the function that actually does the printing.) (CLOSEF? FILENAME) (SETQ FILE (OPENSTREAM FILENAME 'INPUT 'OLD)) (until (EOFP FILE) bind CHAR do (SETQ CHAR (BIN FILE)) (SELECT.MODE CHAR]) (FBITMAP [LAMBDA (BMAP NOROTATE?) (* JBleier "10-FEB-84 21:51") (* This function takes a bit map, and, if the user doesn%'t make an explicit request (using a non-nil NOROTATE? argument), prints the image out rotated -90 degrees using the fast \GETBASEBYTE function.) (PROG ((HEIGHT (fetch BITMAPHEIGHT of BMAP)) (BASE (fetch BITMAPBASE of BMAP)) (BYTESPERROW (ITIMES 2 (fetch BITMAPRASTERWIDTH of BMAP))) COLUMN J CNT OFFSET) (COND (NOROTATE? (BITMAPDISPLAY BMAP)) (T (\PRINTER.MODE 'UniDirectionalOn) (\PRINTER.MODE 'EightSpacingOn) (SETQ OFFSET BYTESPERROW) (for COLUMN from 1 to BYTESPERROW do (GRAPHICS.MODE HEIGHT) (for J from HEIGHT to 1 by -1 do (RS232WRITEBYTE (\GETBASEBYTE BASE (IDIFFERENCE (ITIMES BYTESPERROW J) OFFSET)) T)) (\PRINTER.CRLF) (SETQ OFFSET (SUB1 OFFSET))) (\PRINTER.MODE 'UniDirectionalOff]) (FX.PRESSBITMAP [LAMBDA (FILE BITMAP SCALEFACTOR REGION ROTATION TITLE) (PROG NIL (COND [REGION (SETQ NEWBITMAP (BITMAPCREATE (fetch (REGION WIDTH) of REGION) (fetch (REGION HEIGHT) of REGION] (T (SETQ NEWBITMAP BITMAP))) (\PRINTER.INIT) (BITBLT BITMAP (fetch (REGION LEFT) of REGION) (fetch (REGION BOTTOM) of REGION) NEWBITMAP 0 0 (fetch (REGION WIDTH) of REGION) (fetch (REGION HEIGHT) of REGION)) (RETURN (FBITMAP NEWBITMAP ROTATION]) (FXPRINT [LAMBDA (HOST FILE PRINTOPTIONS) (* Barrera "16-Apr-84 15:17") (SETQ SAVED.SUPPRESS.FLAG SUPPRESS.PAPER.ADJ.FLAG) [COND ((NOT (NULL FILE)) (COND [[NOT (NULL (SETQ COUNTER (LISTGET PRINTOPTIONS '#COPIES] (PROG NIL LOOP(COND ((GEQ COUNTER 1) (RS232.PRINT FILE) (SETQ COUNTER (SUB1 COUNTER)) (RS232WRITEBYTE (CHARCODE FF)) (SETQ SUPPRESS.PAPER.ADJ.FLAG T) (GO LOOP] (T (RS232.PRINT FILE) (RS232WRITEBYTE (CHARCODE FF] (SETQ SUPPRESS.PAPER.ADJ.FLAG SAVED.SUPPRESS.FLAG]) (BITMAPDISPLAY [LAMBDA (BMAP) (* edited: "17-Feb-84 19:09") (* If the user specifies that the Bit Map is to be printed horizontally, then the slow method of printing the imapge via BITMAPBIT is used.) (PROG ((WIDTH (fetch BITMAPWIDTH of BMAP)) CURRENTHT EXP X Y PRINTVAL) (\PRINTER.MODE 'UniDirectionalOn) (\PRINTER.MODE 'EightSpacingOn) (for CURRENTHT from HEIGHT to 0 by -8 do ((GRAPHICS.MODE WIDTH) (for X from 1 to WIDTH do ((SETQ PRINTVAL 0) [for EXP from 7 to 0 by -1 do ((SETQ Y (DIFFERENCE CURRENTHT (DIFFERENCE 7 EXP))) (SETQ PRINTVAL (IPLUS (ITIMES (EXPT 2 EXP) (BITMAPBIT BMAP X Y)) PRINTVAL] (RS232WRITEBYTE PRINTVAL T))) (\PRINTER.CRLF))) (\PRINTER.MODE 'UniDirectionalOff]) (TEXTFILEP [LAMBDA (FILE) (EQ 'TEXT (GETFILEINFO FILE 'TYPE]) (WINDOWDISPLAY [LAMBDA (WINDOW NOROTATE?) (* JBleier "17-Feb-84 18:14") (* This function will print out a window onto the FX-80 printer using the RS232 Port. The image printed will either be printed straight across or rotated by a negative 90 degrees, depending on whether the user specifically requests no rotation in the initial function call.) (PROG (BITMAP) (SETQ BITMAP (WINDOW.TO.BITMAP WINDOW)) (* Because the function \GETBASEBYTE is much faster than BITMAPBIT, and can only work on bit maps, first this function changes the window into a bit map, using WINDOW.TO.BITMAP, then it performs functions upon the created bit map as if it had been called from RS232.PRINT.) (FBITMAP BITMAP NOROTATE?]) (WINDOW.TO.BITMAP [LAMBDA (WINDOW) (* JBleier "17-Feb-84 18:10") (PROG (BITMAP) [SETQ BITMAP (BITMAPCREATE (WINDOWPROP WINDOW 'WIDTH) (WINDOWPROP WINDOW 'HEIGHT] (BITBLT WINDOW NIL NIL BITMAP) (RETURN BITMAP]) (BOLD.MODE [LAMBDA NIL (* JBleier "20-Jan-84 18:17") (* Print Bold pitch) (\PRINTER.MODE 'ProportionalOff) (\PRINTER.MODE 'ExpandOff) (\PRINTER.MODE 'CompressedOn) (\PRINTER.MODE 'BoldOn]) (COMMENT.MODE [LAMBDA NIL (* JBleier "20-Jan-84 18:18") (* Print in subscripted, italicized, compressed pitch) (\PRINTER.MODE 'EliteOff) (\PRINTER.MODE 'BoldOff) (\PRINTER.MODE 'SubScriptOn) (\PRINTER.MODE 'ItalicOn) (\PRINTER.MODE 'CompressedOn]) (EXPANDED.MODE [LAMBDA NIL (* JBleier "20-Jan-84 18:18") (* Print in Expanded pitch) (\PRINTER.MODE 'BoldOff) (\PRINTER.MODE 'EliteOff) (\PRINTER.MODE 'ExpandOn) (\PRINTER.MODE 'ProportionalOn]) (GRAPHICS.MODE [LAMBDA (ROWS) (* edited: "15-JAN-84 17:55") (\PRINTER.COMMAND (CHARCODE "*")) (RS232WRITEBYTE 5 T) (COND ((LESSP ROWS 256) (RS232WRITEBYTE ROWS T) (RS232WRITEBYTE 0 T)) (T (RS232WRITEBYTE (REMAINDER ROWS 256) T) (RS232WRITEBYTE (IQUOTIENT ROWS 256) T]) (SELECT.MODE [LAMBDA (CHAR) (* JBleier "20-Jan-84 18:23") (SELCHARQ CHAR [↑F (* If the character just received from the file is a ↑F, then the next character will dictate mode type. Get that next character and find what mode type to send to the printer.) (SETQ CHAR (BIN FILE)) (SELCHARQ CHAR (↑B (* Print Bold) (BOLD.MODE)) (↑C (* Print Comments) (COMMENT.MODE)) (↑D (* Print Large) (EXPANDED.MODE)) (PROGN (* If the mode is none of the above, then it is either standard mode (↑A), or unknown; in either case, use standard pitch.) (STANDARD.MODE] (CR (\PRINTER.CRLF)) (RS232WRITEBYTE CHAR T]) (STANDARD.MODE [LAMBDA NIL (* edited: "29-DEC-83 18:14") (* Turn off all the previous switches, i.e., print in standard pica. (the function \PRINTER.MODE takes as its argument the mode switch direction, and sends code to the printer via the function \PRINTER.COMMAND that directs the printer to perform the given operation.)) (\PRINTER.MODE 'CompressedOn) (\PRINTER.MODE 'ItalicOff) (\PRINTER.MODE 'ScriptOff) (\PRINTER.MODE 'EliteOff) (\PRINTER.MODE 'ExpandOff) (\PRINTER.MODE 'BoldOff) (\PRINTER.MODE 'ProportionalOff]) (\PRINTER.COMMAND [LAMBDA (CommandChar) (* JBleier "20-Jan-84 18:23") (* Send an Escape, to tell the printer there is to be a mode change, and the then specific mode change, as detailed in PRINTER.MODE.) (RS232WRITEBYTE (CHARCODE ESC) T) (RS232WRITEBYTE CommandChar T]) (\PRINTER.CRLF [LAMBDA NIL (* JBleier "20-Jan-84 18:21") (* Send a carraige return/line feed to the printer; the printer holds all incoming characters in its buffer until it sees a CR/LF.) (RS232WRITEBYTE (CHARCODE CR)) (RS232WRITEBYTE (CHARCODE LF)) (RS232FORCEOUTPUT]) (\PRINTER.HEADING [LAMBDA (FILENAME) (* edited: "29-DEC-83 19:15") (RS232WRITECHARS "Listing of File " T) (RS232WRITECHARS FILENAME T) (RS232WRITECHARS " , " T) (RS232WRITECHARS (DATE) T) (RS232WRITECHARS " by " T) (RS232WRITECHARS (USERNAME) T) (\PRINTER.CRLF) (\PRINTER.CRLF]) (\PRINTER.INIT [LAMBDA NIL (* Barrera "16-Apr-84 15:21") (* This function closes the file to be printed (if necessary.) It also allows the user to specify baud rate. Default on the baud rate is 1200) [COND ((NULL SUPPRESS.PAPER.SET.FLAG) (PROG (BAUDRATE) SLOWPERSON (printout T T T "Set the paper in the printer so that it is about 1/2 inch above the ribbon." T "Remember to turn the printer off first." T T T) (printout T T T) (COND ((NOT (EQ (ASKUSER 7 'Y "Are you all set?(Y/N)") 'Y)) (GO SLOWPERSON] [COND (DEFAULTLOCALBAUDRATE (SETQ BAUDRATE DEFAULTLOCALBAUDRATE)) (T (SETQ BAUDRATE (ASKUSER 60 1200 "What Baud Rate do you want (make sure your printer is set to the same rate)?" '(300 1200 2400 4800 9600] (RS232INIT BAUDRATE 8 NIL 1 'DTR) (SETQ RS232XON\XOFF? T]) (\PRINTER.MODE [LAMBDA (Mode) (* edited: "17-Feb-84 19:40") (* Ths function takes as its argument the mode for the printer to print in, and sends this to the printer via the function \PRINTER.COMMAND.) (SELECTQ Mode (BoldOn (\PRINTER.COMMAND (CHARCODE "E"))) (BoldOff (\PRINTER.COMMAND (CHARCODE "F"))) (CompressedOn (\PRINTER.COMMAND 15)) (CompressedOff (RS232WRITEBYTE 18 T)) (EliteOn (\PRINTER.COMMAND (CHARCODE "M"))) (EliteOff (\PRINTER.COMMAND (CHARCODE "P"))) (ItalicOn (\PRINTER.COMMAND (CHARCODE "4"))) (ItalicOff (\PRINTER.COMMAND (CHARCODE "5"))) (PicaOn (\PRINTER.COMMAND (CHARCODE "P")) (RS232WRITEBYTE 18 T)) (SubScriptOn (\PRINTER.COMMAND (CHARCODE "S")) (RS232WRITEBYTE (CHARCODE "0") T)) (ScriptOff (\PRINTER.COMMAND (CHARCODE "T"))) (SuperScriptOn (\PRINTER.COMMAND (CHARCODE "S")) (RS232WRITEBYTE (CHARCODE "1") T)) (ExpandOn (\PRINTER.COMMAND (CHARCODE "W")) (RS232WRITEBYTE (CHARCODE "1") T)) (ExpandOff (\PRINTER.COMMAND (CHARCODE "W")) (RS232WRITEBYTE (CHARCODE "0")) T) (ProportionalOn (\PRINTER.COMMAND (CHARCODE "p")) (RS232WRITEBYTE (CHARCODE "1") T)) (ProportionalOff (\PRINTER.COMMAND (CHARCODE "p")) (RS232WRITEBYTE (CHARCODE "0") T)) (UniDirectionalOn (\PRINTER.COMMAND (CHARCODE "U")) (RS232WRITEBYTE (CHARCODE "1") T)) (UniDirectionalOff (\PRINTER.COMMAND (CHARCODE "U")) (RS232WRITEBYTE (CHARCODE "0") T)) (SevenSpacingOn (\PRINTER.COMMAND (CHARCODE "1"))) (EightSpacingOn (\PRINTER.COMMAND (CHARCODE "A")) (RS232WRITEBYTE 8 T)) (NineSpacingOn (\PRINTER.COMMAND (CHARCODE "0"))) (TwelveSpacingOn (\PRINTER.COMMAND (CHARCODE "2"))) NIL]) (\PRINTER.PRINT.HEADING [LAMBDA (FILENAME) (* JBleier "20-Jan-84 18:14") (\PRINTER.CRLF) (\PRINTER.MODE 'BoldOn) (\PRINTER.HEADING FILENAME) (\PRINTER.MODE 'BoldOff) (\PRINTER.CRLF]) (\PRINTER.TEXTINIT [LAMBDA NIL (* edited: "17-Feb-84 19:40") (* Perform all of the initialization, including setting the character modes for standard pitch, and making sure that XON\XOFF protocol is used.) (SETQ RS232XON\XOFF? T) (\PRINTER.MODE 'BoldOff) (\PRINTER.MODE 'PicaOn) (\PRINTER.MODE 'ExpandOff) (\PRINTER.MODE 'CompressedOn) (\PRINTER.MODE 'ProportionalOff) (\PRINTER.MODE 'TwelveSpacingOn) (\PRINTER.COMMAND (CHARCODE "N")) (RS232WRITEBYTE 7]) ) (RPAQQ DEFAULTLOCALBAUDRATE NIL) (RPAQQ SUPPRESS.PAPER.SET.FLAG NIL) (PUTPROPS FXPRINTER COPYRIGHT ("Xerox Corporation" 1984)) (DECLARE: DONTCOPY (FILEMAP (NIL (1763 16120 (RS232.PRINT 1773 . 2185) (RS232.PRINTFILE 2187 . 3463) (FBITMAP 3465 . 4592 ) (FX.PRESSBITMAP 4594 . 5164) (FXPRINT 5166 . 5774) (BITMAPDISPLAY 5776 . 6759) (TEXTFILEP 6761 . 6832) (WINDOWDISPLAY 6834 . 7677) (WINDOW.TO.BITMAP 7679 . 7983) (BOLD.MODE 7985 . 8327) (COMMENT.MODE 8329 . 8738) (EXPANDED.MODE 8740 . 9088) (GRAPHICS.MODE 9090 . 9452) (SELECT.MODE 9454 . 10351) ( STANDARD.MODE 10353 . 11020) (\PRINTER.COMMAND 11022 . 11377) (\PRINTER.CRLF 11379 . 11816) ( \PRINTER.HEADING 11818 . 12200) (\PRINTER.INIT 12202 . 13151) (\PRINTER.MODE 13153 . 15167) ( \PRINTER.PRINT.HEADING 15169 . 15441) (\PRINTER.TEXTINIT 15443 . 16118))))) STOP