(FILECREATED "26-Feb-86 08:54:59" {DANTE}<RCLARKE>FXPRINTER>IMAGEWRITER.;21 66078  

      changes to:  (FNS \IW.PRINT.BITMAP \IW.DEFAULTS.MENU IMAGEWRITER \IW.PRINT.TEXT \IW.PRINT.CHAR 
			\IW.PRINT.HEADING IMAGEWRITER.START \IW.SIZE.BITMAP \IW.SIZE.WINDOW 
			\IW.PRINTER.LINES.PER.PAGE \IW.PRINTER.MODE \IW.FILE.ERRORCHECK 
			\IW.SHOW.DEFAULTS \IW.PRINT.FILE \IW.BITMAP.ASK.CORRECTION 
			\IW.PRINTER.LINE.SPACING \IW.WINDOW.ASK.CORRECTION \IW.SET.CORRECTION 
			\IW.EXPLAIN.CORRECTION \IW.ROTATE.BITMAP.RIGHT \IW.EXPLAIN.OPTIONS 
			\IW.INIT.PORT \IW.SET.DEFAULTS \IW.QUIT.OPTION \IW.SELECT.PRINTER.MODE 
			\IW.INIT.TITLE \IW.EXPLAIN.TITLE \IW.SET.TITLE \IW.INIT.CUSTOM.FONT 
			\IW.SET.CUSTOM.FONT.FLG \IW.EXPLAIN.CUSTOM.FONT.FLG \IW.INIT.CENTER.FLG 
			\IW.EXPLAIN.CENTER \IW.SET.CENTER.FLG \IW.INIT.ROTATE.FLG \IW.EXPLAIN.ROTATE 
			\IW.SET.ROTATE.FLG \IW.INIT.SPEED \IW.EXPLAIN.SPEED \IW.SET.SPEED 
			\IW.BOUT.PACK.NUM \IW.STANDARD.MODE \IW.GRAPHICS.MODE \IW.BOLD.MODE 
			\IW.COMMENT.MODE \IW.EXPANDED.MODE \IW.PRINT.TEXT.INIT \IW.LINES.PER.PAGE 
			\IW.PRINTER.COMMAND \IW.PRINT.CRLF \IW.PRINT.CR IMAGEWRITER.PRINT.BITMAP 
			BITMAP.ASK.CORRECTION IMAGEWRITER.EXPLAIN.CORRECTION \PRINTER.MODE 
			IMAGEWRITER.SIZE.BITMAP EXPANDED.MODE IMAGEWRITER.FILE.ERRORCHECK 
			IMAGEWRITER.INIT IMAGEWRITER.DEFAULTS.MENU IMAGEWRITER.SET.DEFAULTS 
			IMAGEWRITER.QUIT.OPTION IMAGEWRITER.PRINT.FILE IMAGEWRITER.PRINT.TEXT 
			PRINT.CHAR IMAGEWRITER.SIZE.WINDOW WINDOW.ASK.CORRECTION 
			IMAGEWRITER.SET.CORRECTION ROTATE.BITMAP.RIGHT IMAGEWRITER.INIT.TITLE 
			IMAGEWRITER.SET.TITLE IMAGEWRITER.INIT.CUSTOM.FONT.FLG 
			IMAGEWRITER.SET.CUSTOM.FONT.FLG IMAGEWRITER.INIT.CENTERFLG 
			IMAGEWRITER.SET.CENTERFLG IMAGEWRITER.INIT.NOROTATE? 
			IMAGEWRITER.SET.NOROTATE? IMAGEWRITER.INIT.SPEED IMAGEWRITER.SET.SPEED 
			BOUT.PACK.NUM \PRINTER.LINES.PER.PAGE \PRINTER.LINE.SPACING \PRINTER.HEADING 
			\PRINTER.PRINT.HEADING)
		   (VARS IMAGEWRITERCOMS)

      previous date: "17-Feb-86 17:12:07" {DANTE}<RCLARKE>FXPRINTER>IMAGEWRITER.;20)


(* Copyright (c) 1986 by XEROX Corporation. All rights reserved.)

(PRETTYCOMPRINT IMAGEWRITERCOMS)

(RPAQQ IMAGEWRITERCOMS ((FILES (LOAD FROM VALUEOF DIRECTORIES)
				 FREEMENU ICONW)
	[ADDVARS (BackgroundMenuCommands ("Imagewriter" (IMAGEWRITER.START)
							"Opens up the IMAGEWRITER command menu"))
		 (PRINTERTYPES ((IMAGE.WRITER LOCALPRINTER)
				(CANPRINT (TEXT BITMAP WINDOW))
				(STATUS TRUE)
				(PROPERTIES NILL)
				(SEND \IW.PRINT.FILE]
	(VARS (BackgroundMenu NIL))
	(VARS IMAGEWRITER.ICON IMAGEWRITER.ICONMASK)
	(* Top level operating functions)
	(FNS IMAGEWRITER.START IMAGEWRITER \IW.EXPLAIN.OPTIONS \IW.FILE.ERRORCHECK \IW.INIT.PORT 
	     \IW.DEFAULTS.MENU \IW.SET.DEFAULTS \IW.SHOW.DEFAULTS \IW.QUIT.OPTION)
	(* These functions do the actual printing of the files)
	(FNS \IW.PRINT.FILE \IW.PRINT.TEXT \IW.SELECT.PRINTER.MODE \IW.PRINT.CHAR \IW.PRINT.BITMAP 
	     \IW.SIZE.BITMAP \IW.BITMAP.ASK.CORRECTION \IW.SIZE.WINDOW \IW.WINDOW.ASK.CORRECTION 
	     \IW.SET.CORRECTION \IW.EXPLAIN.CORRECTION \IW.ROTATE.BITMAP.RIGHT)
	(* These functions create and implement menu operations)
	(FNS \IW.INIT.TITLE \IW.EXPLAIN.TITLE \IW.SET.TITLE \IW.INIT.CUSTOM.FONT 
	     \IW.SET.CUSTOM.FONT.FLG \IW.EXPLAIN.CUSTOM.FONT.FLG \IW.INIT.CENTER.FLG 
	     \IW.EXPLAIN.CENTER \IW.SET.CENTER.FLG \IW.INIT.ROTATE.FLG \IW.EXPLAIN.ROTATE 
	     \IW.SET.ROTATE.FLG \IW.INIT.SPEED \IW.EXPLAIN.SPEED \IW.SET.SPEED)
	(* These functions setup the printer modes)
	(FNS \IW.BOUT.PACK.NUM \IW.STANDARD.MODE \IW.GRAPHICS.MODE \IW.BOLD.MODE \IW.COMMENT.MODE 
	     \IW.EXPANDED.MODE \IW.PRINT.TEXT.INIT \IW.PRINTER.LINES.PER.PAGE 
	     \IW.PRINTER.LINE.SPACING \IW.PRINT.HEADING \IW.PRINTER.COMMAND \IW.PRINT.CRLF 
	     \IW.PRINT.CR \IW.PRINTER.MODE)
	(INITVARS (IMAGEWRITER.PORT (QUOTE RS232C))
		  (IMAGEWRITER.PROTOCOL (QUOTE XOnXOff))
		  (IMAGEWRITER.BAUD.RATE 9600)
		  (IMAGEWRITER.PAPER.LENGTH 11)
		  (IMAGEWRITER.LINES.PER.PAGE 60)
		  (IMAGEWRITER.LINES.PER.INCH 6)
		  (IMAGEWRITER.LMARGIN 3)
		  (IMAGEWRITER.RMARGIN 96)
		  (IMAGEWRITER.CHAR.PITCH (QUOTE Elite))
		  (IMAGEWRITER.BITWIDTH 576)
		  (IW.PRINT.TITLE (QUOTE NO))
		  (IW.CENTER.IMAGE (QUOTE NO))
		  (IW.ROTATE.IMAGE (QUOTE YES))
		  (IW.PRINT.WINDOW.BORDERS (QUOTE YES))
		  (IW.LOAD.CUSTOM.FONT (QUOTE NO))
		  (IW.CUSTOM.FONT.FILENAME (QUOTE NONE))
		  (IW.OUTSTREAM NIL)
		  (IW.RS232PORT.STREAM NIL)
		  (IW.TTYPORT.STREAM NIL))
	(GLOBALVARS IW.DISPLAY IW.MENU.WINDOW IW.WINDOW IW.DEFAULT.SELECT.MENUWINDOW IW.INPUT.FILE 
		    IW.USER.INFILE IMAGEWRITER.PORT IMAGEWRITER.BAUD.RATE IMAGEWRITER.PROTOCOL 
		    IMAGEWRITER.PAPER.LENGTH IMAGEWRITER.LINES.PER.PAGE IMAGEWRITER.CHAR.PITCH 
		    IMAGEWRITER.BITWIDTH IMAGEWRITER.LMARGIN IMAGEWRITER.RMARGIN IW.PRINT.TITLE 
		    IW.CENTER.IMAGE IW.ROTATE.IMAGE IW.PRINT.WINDOW.BORDERS IW.LOAD.CUSTOM.FONT 
		    IW.CUSTOM.FONT.FILENAME IMAGEWRITER.LINE.LENGTH IW.PRINTLINECOUNT IW.OUTSTREAM 
		    IW.RS232PORT.STREAM IW.TTYPORT.STREAM IW.LINEBUFFER IW.CHAR.COUNT IW.INPUT.CHAR 
		    IW.OUTPUT.BITMAP IW.ALT.SELECTION)))
(FILESLOAD (LOAD FROM VALUEOF DIRECTORIES)
	   FREEMENU ICONW)

(ADDTOVAR BackgroundMenuCommands ("Imagewriter" (IMAGEWRITER.START)
						  "Opens up the IMAGEWRITER command menu"))

(ADDTOVAR PRINTERTYPES ((IMAGE.WRITER LOCALPRINTER)
			  (CANPRINT (TEXT BITMAP WINDOW))
			  (STATUS TRUE)
			  (PROPERTIES NILL)
			  (SEND \IW.PRINT.FILE)))

(RPAQQ BackgroundMenu NIL)

(RPAQ IMAGEWRITER.ICON (READBITMAP))
(50 50
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@GOOOOO@@@@@@"
"@@@@D@@@@A@@@@@@"
"@@@@D@@@@A@@@@@@"
"@@@@DCOOOI@@@@@@"
"@@@@D@@@@A@@@@@@"
"@@@GEOOOOI@AL@@@"
"@@@ID@@@@A@BD@@@"
"@@ACEOOOOI@DL@@@"
"@@BED@@@@A@ID@@@"
"@@DIMOOOOIOBD@@@"
"@@IBD@@@@ABDD@@@"
"@ABGMOL@@ALHD@@@"
"@BDHD@@@@AI@D@@@"
"@DIOOOOOOOB@D@@@"
"@IB@@@@@@BD@D@@@"
"ABD@@@@@@DH@D@@@"
"BDH@@@@@@I@@D@@@"
"GI@@@@@@AN@@H@@@"
"DJ@@@@@@AB@A@@@@"
"DOOOOOOOOB@B@@@@"
"DH@@@@@@AB@D@@@@"
"DOOOOOOOOB@H@@@@"
"DH@@@@@@ABA@@@@@"
"DH@@@@@@ABB@@@@@"
"DH@@@@@@ABD@@@@@"
"DH@@@@@@ABH@@@@@"
"DH@@@@@@AC@@@@@@"
"GOOOOOOOON@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@")

(RPAQ IMAGEWRITER.ICONMASK (READBITMAP))
(50 50
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@GOOOOO@@@@@@"
"@@@@GOOOOO@@@@@@"
"@@@@GOOOOO@@@@@@"
"@@@@GOOOOO@@@@@@"
"@@@@GOOOOO@@@@@@"
"@@@GGOOOOO@AL@@@"
"@@@OGOOOOO@CL@@@"
"@@AOGOOOOO@GL@@@"
"@@COGOOOOO@OL@@@"
"@@GOOOOOOOOOL@@@"
"@@OOOOOOOOOOL@@@"
"@AOOOOOOOOOOL@@@"
"@COOOOOOOOOOL@@@"
"@GOOOOOOOOOOL@@@"
"@OOOOOOOOOOOL@@@"
"AOOOOOOOOOOOL@@@"
"COOOOOOOOOOOL@@@"
"GOOOOOOOOOOOH@@@"
"GOOOOOOOOOOO@@@@"
"GOOOOOOOOOON@@@@"
"GOOOOOOOOOOL@@@@"
"GOOOOOOOOOOH@@@@"
"GOOOOOOOOOO@@@@@"
"GOOOOOOOOON@@@@@"
"GOOOOOOOOOL@@@@@"
"GOOOOOOOOOH@@@@@"
"GOOOOOOOOO@@@@@@"
"GOOOOOOOON@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@")



(* Top level operating functions)

(DEFINEQ

(IMAGEWRITER.START
  [LAMBDA NIL                                                (* edited: "17-Feb-86 17:11")
    (PROG (POS IMAGEWRITER.MENU)
	    (SETQ IMAGEWRITER.MENU (create MENU
					       ITEMS ←(QUOTE (START STOP SET))
					       MENUROWS ← 1
					       ITEMWIDTH ← 80
					       CENTERFLG ← T
					       MENUFONT ←(FONTCREATE (QUOTE MODERN)
								       10
								       (QUOTE BOLD))
					       MENUBORDERSIZE ← 3
					       WHENSELECTEDFN ←(QUOTE IMAGEWRITER)
					       WHENHELDFN ←(QUOTE \IW.EXPLAIN.OPTIONS)))
	    (PROMPTPRINT "Please indicate a region for IMAGEWRITER")
	    (SETQ IW.DISPLAY (CREATEW (QUOTE (0 0 220 24))
					  NIL 5 T))
	    (SETQ POS (GETBOXPOSITION 200 59))
	    (CLEARW PROMPTWINDOW)
	    (MOVEW IW.DISPLAY (CAR POS)
		     (PLUS (CDR POS)
			     36))
	    (SETQ IW.MENU.WINDOW (MENUWINDOW IMAGEWRITER.MENU))
	    (SETQ IW.WINDOW (ATTACHWINDOW IW.MENU.WINDOW IW.DISPLAY (QUOTE BOTTOM)
					      (QUOTE JUSTIFY)))
	    (WINDOWPROP IW.DISPLAY (QUOTE CLOSEFN)
			  (QUOTE (\IW.QUIT.OPTION)))
	    (WINDOWPROP IW.DISPLAY (QUOTE ICONWINDOW)
			  NIL)
	    (WINDOWPROP IW.DISPLAY (QUOTE ICON)
			  (ICONW IMAGEWRITER.ICON IMAGEWRITER.ICONMASK (QUOTE (200 . 200))
				   T))
	    (DSPFONT (FONTCREATE (QUOTE TIMESROMAN)
				     10
				     (QUOTE BOLD))
		       IW.DISPLAY)
	    (CLEARW IW.DISPLAY)
	    (CENTERPRINTINREGION "IMAGEWRITER" NIL IW.DISPLAY])

(IMAGEWRITER
  [LAMBDA (COMMAND)                                        (* edited: "15-Feb-86 13:55")
    (SELECTQ COMMAND
	       (SET (\IW.DEFAULTS.MENU))
	       (STOP (DEL.PROCESS (QUOTE IMAGEWRITER.PRINTING))
		     [if (INFILEP IW.INPUT.FILE)
			 then (CLOSEF? IW.INPUT.FILE)
				(BOUT IW.OUTSTREAM (CHARCODE FF))
				(FORCEOUTPUT IW.OUTSTREAM)
		       else (PROG (TABUP TEMPLINESPERPAGE LINESPERPAGE)
				      (SETQ TEMPLINESPERPAGE (SETQ LINESPERPAGE (ITIMES 
									 IMAGEWRITER.PAPER.LENGTH 9)))
				  TRYAGAIN
				      (if (LEQ (SETQ TABUP (IDIFFERENCE TEMPLINESPERPAGE 
										IW.PRINTLINECOUNT))
						   0)
					  then (SETQ TEMPLINESPERPAGE (IPLUS TEMPLINESPERPAGE 
										   LINESPERPAGE))
						 (GO TRYAGAIN))
				      (from 0 to TABUP do (\IW.PRINT.CRLF]
		     (\IW.PRINTER.MODE (QUOTE Reset))
		     (\IW.PRINTER.MODE (QUOTE ClearBuffer))
		     (\IW.PRINTER.LINE.SPACING IMAGEWRITER.LINES.PER.INCH)
		     (\IW.PRINTER.LINES.PER.PAGE IMAGEWRITER.LINES.PER.PAGE)
		     (\IW.PRINTER.MODE (QUOTE UniDirectionalOff))
		     (CLEARW IW.DISPLAY)
		     (CENTERPRINTINREGION "IMAGEWRITER" NIL IW.DISPLAY))
	       (START [if (EQ IMAGEWRITER.PORT (QUOTE RS232C))
			  then (if (NOT (BOUNDP (QUOTE \RS232C.READY)))
				     then (LOAD? (QUOTE DLRS232C.DCOM)))
			else (if (NOT (BOUNDP (QUOTE \TTY.READY)))
				   then (LOAD? (QUOTE DLTTY.DCOM]
		      (CLEARW PROMPTWINDOW)
		      (CLEARW IW.DISPLAY)
		      (SETQ IW.INPUT.FILE (U-CASE (PROMPTFORWORD "Input file: " NIL NIL 
								       IW.DISPLAY)))
		      (SETQ IW.USER.INFILE IW.INPUT.FILE)
		      (CLEARW IW.DISPLAY)
		      (CENTERPRINTINREGION "~~~~~  THINKING  ~~~~~" NIL IW.DISPLAY)
		      (if (\IW.FILE.ERRORCHECK IW.INPUT.FILE)
			  then (if [NOT (FMEMB IMAGEWRITER.BAUD.RATE
						       (QUOTE (300 1200 2400 9600]
				     then (\IW.INIT.SPEED))
				 (if [NOT (FMEMB IW.PRINT.TITLE (QUOTE (YES NO]
				     then (\IW.INIT.TITLE))
				 (if (INFILEP IW.INPUT.FILE)
				     then (if [NOT (FMEMB IW.LOAD.CUSTOM.FONT
								  (QUOTE (YES NO]
						then (\IW.INIT.CUSTOM.FONT)))
				 (if (NOT (INFILEP IW.INPUT.FILE))
				     then (if [NOT (FMEMB IW.ROTATE.IMAGE
								  (QUOTE (YES NO]
						then (\IW.INIT.ROTATE.FLG))
					    (if [NOT (FMEMB IW.CENTER.IMAGE
								  (QUOTE (YES NO]
						then (\IW.INIT.CENTER.FLG)))
				 (\IW.INIT.PORT IMAGEWRITER.PORT IMAGEWRITER.BAUD.RATE 
						  IMAGEWRITER.PROTOCOL)
				 (CLEARW IW.DISPLAY)
				 (CENTERPRINTINREGION "~~~~ SCANNING ~~~~" NIL IW.DISPLAY)
				 (\IW.PRINT.FILE IW.INPUT.FILE)
			else (CLEARW IW.DISPLAY)
			       (CENTERPRINTINREGION "IMAGEWRITER" NIL IW.DISPLAY)
			       (CLEARW)
			       (printout T T IW.INPUT.FILE " file not found. IMAGEWRITER terminate" T 
					 T)
			       (RINGBELLS)))
	       (SHOULDNT])

(\IW.EXPLAIN.OPTIONS
  [LAMBDA (ITEM)                                             (* edited: " 3-Feb-86 11:01")
    (SELECTQ ITEM
	       (START (PROMPTPRINT "Print file, bitmap, or window on the APPLE IMAGEWRITER printer")
		      )
	       (STOP (PROMPTPRINT "Immediately stops printing the current file"))
	       (SET (PROMPTPRINT "Allows you to see and set Imagewriter default settings"))
	       (SHOULDNT])

(\IW.FILE.ERRORCHECK
  [LAMBDA (FILE)                                             (* edited: "13-Feb-86 15:25")
    (if (INFILEP FILE)
	then (SETQ IW.INPUT.FILE (INFILEP FILE))
	       T
      elseif (EQ (MKATOM FILE)
		     (QUOTE WHICHW))
	then [SETQ IW.INPUT.FILE (EVAL (LIST (MKATOM FILE]
	       T
      elseif (EQ (MKATOM FILE)
		     (QUOTE SCREENBITMAP))
	then [SETQ IW.INPUT.FILE (EVAL (LIST (MKATOM FILE]
	       T
      elseif (BOUNDP (MKATOM FILE))
	then (if (BITMAPP (EVAL (MKATOM FILE)))
		   then (SETQ IW.INPUT.FILE (EVAL (MKATOM FILE)))
			  T
		 elseif (WINDOWP (EVAL (MKATOM FILE)))
		   then (SETQ IW.INPUT.FILE (EVAL (MKATOM FILE)))
			  T
		 else NIL)
      else NIL])

(\IW.INIT.PORT
  [LAMBDA (PORT BAUD PROTOCOL)                               (* edited: "15-Feb-86 13:13")
    (SELECTQ PORT
	       (RS232C (if (AND \RS232C.READY (EQ [CDAR (RS232C.GET.PARAMETERS
								  (QUOTE (BaudRate]
							BAUD))
			   then (SETQ IW.OUTSTREAM IW.RS232PORT.STREAM)
			 else (RS232C.INIT BAUD 8 (QUOTE NONE)
					       1 PROTOCOL)
				(SETQ IW.RS232PORT.STREAM (OPENSTREAM (QUOTE {RS232})
									  (QUOTE OUTPUT)))
				(SETQ IW.OUTSTREAM IW.RS232PORT.STREAM)))
	       (TTY (if (AND \TTY.READY (EQ [CDAR (TTY.GET.PARAMETERS (QUOTE (BaudRate]
						  BAUD))
			then (SETQ IW.OUTSTREAM IW.TTYPORT.STREAM)
		      else (TTY.INIT BAUD 8 (QUOTE NONE)
					 1 PROTOCOL)
			     (SETQ IW.TTYPORT.STREAM (OPENSTREAM (QUOTE {TTY})
								     (QUOTE OUTPUT)))
			     (SETQ IW.OUTSTREAM IW.TTYPORT.STREAM)))
	       (SHOULDNT))
    (LINELENGTH (IDIFFERENCE IMAGEWRITER.RMARGIN IMAGEWRITER.LMARGIN)
		  IW.OUTSTREAM])

(\IW.DEFAULTS.MENU
  [LAMBDA NIL                                                (* edited: "26-Feb-86 08:51")
    (PROG (MENU.DESCRIPTION)
	    [SETQ MENU.DESCRIPTION (QUOTE (((TYPE MOMENTARY LABEL APPLY FONT (MODERN 10 BOLD)
						      SELECTEDFN \IW.SET.DEFAULTS))
						((TYPE MOMENTARY LABEL SHOW FONT (MODERN 10 BOLD)
						       SELECTEDFN \IW.SHOW.DEFAULTS))
						((TYPE TITLE LABEL Port FONT (MODERN 10 BOLD))
						 (TYPE NWAY ID PORT LABEL RS232C)
						 (TYPE NWAY ID PORT LABEL TTY))
						((TYPE TITLE LABEL Protocol FONT (MODERN 10 BOLD))
						 (TYPE NWAY ID PROTOCOL LABEL XOnXOff)
						 (TYPE NWAY ID PROTOCOL LABEL DTR))
						((TYPE TITLE LABEL "BaudRate: " FONT
						       (MODERN 10 BOLD))
						 (TYPE NWAY ID BAUDRATE LABEL 300)
						 (TYPE NWAY ID BAUDRATE LABEL 1200)
						 (TYPE NWAY ID BAUDRATE LABEL 2400)
						 (TYPE NWAY ID BAUDRATE LABEL 9600))
						((TYPE TITLE LABEL "Paper Length: " FONT
						       (MODERN 10 BOLD))
						 (TYPE EDITSTART LABEL "" ITEMS (PAPERLENGTH))
						 (TYPE EDIT ID PAPERLENGTH LABEL ""))
						((TYPE TITLE LABEL "Lines Per Inch: " FONT
						       (MODERN 10 BOLD))
						 (TYPE EDITSTART LABEL "" ITEMS (LPI))
						 (TYPE EDIT ID LPI LABEL ""))
						((TYPE TITLE LABEL "Lines Per Page: " FONT
						       (MODERN 10 BOLD))
						 (TYPE EDITSTART LABEL "" ITEMS (LPP))
						 (TYPE EDIT ID LPP LABEL ""))
						((TYPE TITLE LABEL "Char Pitch: " FONT
						       (MODERN 10 BOLD))
						 (TYPE NCHOOSE LABEL "" ID CHARPITCH ITEMS
						       (Extended Pica Elite PicaProportional 
								 EliteProportional Semicondensed 
								 Condensed Ultracondensed)))
						((TYPE TITLE LABEL "Bit Per Line: " FONT
						       (MODERN 10 BOLD))
						 (TYPE EDITSTART LABEL "" ITEMS (BITWIDTH))
						 (TYPE EDIT ID BITWIDTH LABEL ""))
						((TYPE TITLE LABEL "Left Margin: " FONT
						       (MODERN 10 BOLD))
						 (TYPE EDITSTART LABEL "" ITEMS (LMARGIN))
						 (TYPE EDIT ID LMARGIN LABEL ""))
						((TYPE TITLE LABEL "Right Margin:" FONT
						       (MODERN 10 BOLD))
						 (TYPE EDITSTART LABEL "" ITEMS (RMARGIN))
						 (TYPE EDIT ID RMARGIN LABEL ""))
						((TYPE TITLE LABEL "Print Title: " FONT
						       (MODERN 10 BOLD))
						 (TYPE NCHOOSE LABEL "" ID TITLE ITEMS (YES NO)))
						((TYPE TITLE LABEL "Rotate Image: " FONT
						       (MODERN 10 BOLD))
						 (TYPE NCHOOSE LABEL "" ID ROTATE ITEMS (YES NO)))
						((TYPE TITLE LABEL "Center Image: " FONT
						       (MODERN 10 BOLD))
						 (TYPE NCHOOSE LABEL "" ID CENTER ITEMS (YES NO)))
						((TYPE TITLE LABEL "Print Window Borders: " FONT
						       (MODERN 10 BOLD))
						 (TYPE NCHOOSE LABEL "" ID WINDOWBORDER ITEMS
						       (YES NO)))
						((TYPE TITLE LABEL "Load Custom Font: " FONT
						       (MODERN 10 BOLD))
						 (TYPE NCHOOSE LABEL "" ID FONT ITEMS (YES NO)))
						((TYPE TITLE LABEL "Font File Name: " FONT
						       (MODERN 10 BOLD))
						 (TYPE EDITSTART LABEL "" ITEMS (FONTFILENAME))
						 (TYPE EDIT ID FONTFILENAME LABEL ""))
						(WINDOWPROPS TITLE "Imagewriter Default Settings" 
							     BORDER 5 LEFT 400 BOTTOM 400]
	    (SETQ IW.DEFAULT.SELECT.MENUWINDOW (FM.FORMATMENU MENU.DESCRIPTION))
	    (\IW.SHOW.DEFAULTS)
	    (OPENW IW.DEFAULT.SELECT.MENUWINDOW)
	    (MOVEW IW.DEFAULT.SELECT.MENUWINDOW])

(\IW.SET.DEFAULTS
  [LAMBDA NIL                                                (* edited: "13-Feb-86 10:38")
    (PROG (DEFAULT.LIST)
	    (SETQ DEFAULT.LIST (FM.READSTATE IW.DEFAULT.SELECT.MENUWINDOW))
	    (SETQ IMAGEWRITER.PORT (LISTGET DEFAULT.LIST (QUOTE PORT)))
	    [SETQ IMAGEWRITER.PROTOCOL (MKATOM (LISTGET DEFAULT.LIST (QUOTE PROTOCOL]
	    (SETQ IMAGEWRITER.BAUD.RATE (LISTGET DEFAULT.LIST (QUOTE BAUDRATE)))
	    [SETQ IMAGEWRITER.PAPER.LENGTH (MKATOM (LISTGET DEFAULT.LIST (QUOTE PAPERLENGTH]
	    [SETQ IMAGEWRITER.LINES.PER.INCH (MKATOM (LISTGET DEFAULT.LIST (QUOTE LPI]
	    [SETQ IMAGEWRITER.LINES.PER.PAGE (MKATOM (LISTGET DEFAULT.LIST (QUOTE LPP]
	    [SETQ IMAGEWRITER.CHAR.PITCH (MKATOM (LISTGET DEFAULT.LIST (QUOTE CHARPITCH]
	    [SETQ IMAGEWRITER.BITWIDTH (MKATOM (LISTGET DEFAULT.LIST (QUOTE BITWIDTH]
	    [SETQ IMAGEWRITER.LMARGIN (MKATOM (LISTGET DEFAULT.LIST (QUOTE LMARGIN]
	    [SETQ IMAGEWRITER.RMARGIN (MKATOM (LISTGET DEFAULT.LIST (QUOTE RMARGIN]
	    (SETQ IW.PRINT.TITLE (LISTGET DEFAULT.LIST (QUOTE TITLE)))
	    (SETQ IW.ROTATE.IMAGE (LISTGET DEFAULT.LIST (QUOTE ROTATE)))
	    (SETQ IW.CENTER.IMAGE (LISTGET DEFAULT.LIST (QUOTE CENTER)))
	    (SETQ IW.PRINT.WINDOW.BORDERS (LISTGET DEFAULT.LIST (QUOTE WINDOWBORDER)))
	    (SETQ IW.LOAD.CUSTOM.FONT (LISTGET DEFAULT.LIST (QUOTE FONT)))
	    (SETQ IW.CUSTOM.FONT.FILENAME (LISTGET DEFAULT.LIST (QUOTE FONTFILENAME])

(\IW.SHOW.DEFAULTS
  [LAMBDA NIL                                                (* edited: "13-Feb-86 14:07")
    (FM.CHANGESTATE (FM.ITEMFROMID IW.DEFAULT.SELECT.MENUWINDOW IMAGEWRITER.PORT)
		      IW.DEFAULT.SELECT.MENUWINDOW)
    (FM.CHANGESTATE (FM.ITEMFROMID IW.DEFAULT.SELECT.MENUWINDOW IMAGEWRITER.PROTOCOL)
		      IW.DEFAULT.SELECT.MENUWINDOW)
    (FM.CHANGESTATE (FM.ITEMFROMID IW.DEFAULT.SELECT.MENUWINDOW IMAGEWRITER.BAUD.RATE)
		      IW.DEFAULT.SELECT.MENUWINDOW)
    (FM.CHANGESTATE (FM.ITEMFROMID IW.DEFAULT.SELECT.MENUWINDOW (QUOTE PAPERLENGTH))
		      IW.DEFAULT.SELECT.MENUWINDOW IMAGEWRITER.PAPER.LENGTH)
    (FM.CHANGESTATE (FM.ITEMFROMID IW.DEFAULT.SELECT.MENUWINDOW (QUOTE LPI))
		      IW.DEFAULT.SELECT.MENUWINDOW IMAGEWRITER.LINES.PER.INCH)
    (FM.CHANGESTATE (FM.ITEMFROMID IW.DEFAULT.SELECT.MENUWINDOW (QUOTE LPP))
		      IW.DEFAULT.SELECT.MENUWINDOW IMAGEWRITER.LINES.PER.PAGE)
    (FM.CHANGESTATE (FM.ITEMFROMID IW.DEFAULT.SELECT.MENUWINDOW (QUOTE BITWIDTH))
		      IW.DEFAULT.SELECT.MENUWINDOW IMAGEWRITER.BITWIDTH)
    (FM.CHANGESTATE (FM.ITEMFROMID IW.DEFAULT.SELECT.MENUWINDOW (QUOTE RMARGIN))
		      IW.DEFAULT.SELECT.MENUWINDOW IMAGEWRITER.RMARGIN)
    (FM.CHANGESTATE (FM.ITEMFROMID IW.DEFAULT.SELECT.MENUWINDOW (QUOTE LMARGIN))
		      IW.DEFAULT.SELECT.MENUWINDOW IMAGEWRITER.LMARGIN)
    (FM.CHANGESTATE (FM.ITEMFROMID IW.DEFAULT.SELECT.MENUWINDOW (QUOTE TITLE))
		      IW.DEFAULT.SELECT.MENUWINDOW IW.PRINT.TITLE)
    (FM.CHANGESTATE (FM.ITEMFROMID IW.DEFAULT.SELECT.MENUWINDOW (QUOTE ROTATE))
		      IW.DEFAULT.SELECT.MENUWINDOW IW.ROTATE.IMAGE)
    (FM.CHANGESTATE (FM.ITEMFROMID IW.DEFAULT.SELECT.MENUWINDOW (QUOTE CENTER))
		      IW.DEFAULT.SELECT.MENUWINDOW IW.CENTER.IMAGE)
    (FM.CHANGESTATE (FM.ITEMFROMID IW.DEFAULT.SELECT.MENUWINDOW (QUOTE CHARPITCH))
		      IW.DEFAULT.SELECT.MENUWINDOW IMAGEWRITER.CHAR.PITCH)
    (FM.CHANGESTATE (FM.ITEMFROMID IW.DEFAULT.SELECT.MENUWINDOW (QUOTE WINDOWBORDER))
		      IW.DEFAULT.SELECT.MENUWINDOW IW.PRINT.WINDOW.BORDERS)
    (FM.CHANGESTATE (FM.ITEMFROMID IW.DEFAULT.SELECT.MENUWINDOW (QUOTE FONT))
		      IW.DEFAULT.SELECT.MENUWINDOW IW.LOAD.CUSTOM.FONT)
    (FM.CHANGESTATE (FM.ITEMFROMID IW.DEFAULT.SELECT.MENUWINDOW (QUOTE FONTFILENAME))
		      IW.DEFAULT.SELECT.MENUWINDOW IW.CUSTOM.FONT.FILENAME])

(\IW.QUIT.OPTION
  [LAMBDA (OPTION)                                           (* edited: "13-Feb-86 10:49")
    (if (EQ IMAGEWRITER.PORT (QUOTE RS232C))
	then (RS232C.SHUTDOWN)
      else (TTY.SHUTDOWN))
    (CLOSEF? IW.RS232PORT.STREAM)
    (CLOSEF? IW.TTYPORT.STREAM)
    (CLOSEW IW.MENU.WINDOW])
)



(* These functions do the actual printing of the files)

(DEFINEQ

(\IW.PRINT.FILE
  [LAMBDA (FILE)                                             (* edited: "13-Feb-86 13:39")
    (if (INFILEP FILE)
	then (SETQ TEXT.FILE FILE)
	       (ADD.PROCESS (QUOTE (\IW.PRINT.TEXT (FULLNAME TEXT.FILE)))
			      (QUOTE NAME)
			      (QUOTE IMAGEWRITER.PRINTING))
      elseif (BITMAPP FILE)
	then (\IW.SIZE.BITMAP FILE)
      else (\IW.SIZE.WINDOW FILE])

(\IW.PRINT.TEXT
  [LAMBDA (FILENAME)                                         (* edited: "14-Feb-86 08:16")

          (* This function takes a file, opens it for stream input , and prints that file on an Imagewriter Printer.
	  NOTE: check the documentation for this program for the correct pin connections for you particular machine.)


    (PROG (FILE FONTFILE)                                  (* Load Custom Font)
	    (if (EQ IW.LOAD.CUSTOM.FONT (QUOTE YES))
		then (if (SETQ FONTFILE (INFILEP IW.CUSTOM.FONT.FILENAME))
			   then (CLOSEF? FONTFILE)
				  (COPYBYTES (OPENSTREAM FONTFILE (QUOTE INPUT)
							     (QUOTE OLD))
					       IW.OUTSTREAM 1 (GETEOFPTR FONTFILE))
				  (FORCEOUTPUT IW.OUTSTREAM)
				  (CLOSEF FONTFILE)
			 else (RINGBELLS 2)
				(PROMPTPRINT "Font file not found. Press stop to halt printing.")))
	    (CLOSEF? FILENAME)
	    (SETQ FILE (OPENSTREAM FILENAME (QUOTE INPUT)
				       (QUOTE OLD)))
	    (SETQ IW.LINEBUFFER "")
	    (SETQ IMAGEWRITER.LINE.LENGTH (IDIFFERENCE IMAGEWRITER.RMARGIN IMAGEWRITER.LMARGIN))
	    (SETQ IW.CHAR.COUNT IMAGEWRITER.LINE.LENGTH)
	    (\IW.PRINT.TEXT.INIT)
	    (CLEARW IW.DISPLAY)
	    (CENTERPRINTINREGION "~~~~~  PRINTING  ~~~~~" NIL IW.DISPLAY)
	    (if (EQ IW.PRINT.TITLE (QUOTE YES))
		then (\IW.PRINT.HEADING FILENAME))
	    (until (EOFP FILE) bind CHAR
	       do (SETQ IW.INPUT.CHAR (BIN FILE))
		    (\IW.SELECT.PRINTER.MODE IW.INPUT.CHAR FILE))
	    (PRIN1 IW.LINEBUFFER IW.OUTSTREAM)
	    (BOUT IW.OUTSTREAM (CHARCODE FF))            (* Go back to the standard font)
	    (BOUT IW.OUTSTREAM (CHARCODE ESC))
	    (BOUT IW.OUTSTREAM (CHARCODE "$"))
	    (FORCEOUTPUT IW.OUTSTREAM)
	    (CLOSEF? FILE)
	    (CLEARW IW.DISPLAY)
	    (CENTERPRINTINREGION "IMAGEWRITER" NIL IW.DISPLAY])

(\IW.SELECT.PRINTER.MODE
  [LAMBDA (CHAR FILE)                                        (* edited: "13-Feb-86 12:01")
    (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)
				(\IW.BOLD.MODE))
			    (↑C                              (* Print Comments)
				(\IW.COMMENT.MODE))
			    (↑D                              (* Print Large)
				(\IW.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.)


				     (\IW.STANDARD.MODE]
	      (\IW.PRINT.CHAR CHAR])

(\IW.PRINT.CHAR
  [LAMBDA (CHAR)                                             (* edited: "15-Feb-86 13:02")
    (PROG (LASTSPACE)
	    (SETQ IW.LINEBUFFER (CONCAT IW.LINEBUFFER (CHARACTER CHAR)))
	    (SETQ IW.CHAR.COUNT (SUB1 IW.CHAR.COUNT))

          (* Output the line buffer if there is a Carriage Return (13) else Do word wrap if necessary.
	  Look for Space starting at end of line and then output linebuffer up to that space. Put next word in the a fresh 
	  line buffer)


	    (if (EQ CHAR 13)
		then (PRIN1 IW.LINEBUFFER IW.OUTSTREAM)
		       (if (EQ IMAGEWRITER.PORT (QUOTE RS232C))
			   then (\IW.PRINT.CRLF)
			 else (\IW.PRINT.CR))
		       (SETQ IW.CHAR.COUNT IMAGEWRITER.LINE.LENGTH)
		       (SETQ IW.LINEBUFFER "")
	      else (if (EQ IW.CHAR.COUNT 0)
			 then (SETQ LASTSPACE (STRPOS " " IW.LINEBUFFER NIL NIL NIL NIL NIL T))
				(PRIN1 (SUBSTRING IW.LINEBUFFER 1 LASTSPACE)
					 IW.OUTSTREAM)
				(if (EQ IMAGEWRITER.PORT (QUOTE RS232C))
				    then (\IW.PRINT.CRLF)
				  else (\IW.PRINT.CR))
				(if [OR (NULL LASTSPACE)
					    (NULL (SETQ IW.LINEBUFFER (SUBSTRING IW.LINEBUFFER
										       (IPLUS
											 LASTSPACE 1]
				    then (SETQ IW.LINEBUFFER ""))
				(SETQ IW.CHAR.COUNT (IDIFFERENCE IMAGEWRITER.LINE.LENGTH
								     (NCHARS IW.LINEBUFFER])

(\IW.PRINT.BITMAP
  [LAMBDA (BMAP)                                             (* edited: "17-Feb-86 09:17")
    (PROG (COLUMN I J CNT OFFSET BASE BYTESPERROW OFFSET PTR HEIGHT WIDTH CENTER.DOWN CENTER.LEFT 
		    IMAGEWRITER.SCREENDUMP TEMPLINESPERPAGE LINESPERPAGE TABUP)
	    (SETQ HEIGHT (BITMAPHEIGHT BMAP))
	    (SETQ WIDTH (BITMAPWIDTH BMAP))
	    (SETQ BASE (fetch BITMAPBASE of BMAP))
	    (SETQ BYTESPERROW (ITIMES 2 (fetch BITMAPRASTERWIDTH of BMAP)))
	    (SETQ OFFSET (DIFFERENCE BYTESPERROW 1))
	    (SETQ IW.PRINTLINECOUNT 0)
	    (\IW.PRINTER.LINE.SPACING 9)
	    (\IW.PRINTER.MODE (QUOTE ResetTabTOF))
	    (\IW.PRINTER.MODE (QUOTE Extended))
	    (\IW.PRINTER.MODE (QUOTE UniDirectionalOff))
	    (\IW.PRINTER.COMMAND (CHARCODE "L"))
	    (\IW.BOUT.PACK.NUM 0 3)
	    (CLEARW IW.DISPLAY)
	    (CENTERPRINTINREGION "~~~~~  PRINTING  ~~~~~" NIL IW.DISPLAY)
	    (if (EQ IW.PRINT.TITLE (QUOTE YES))
		then (\IW.PRINT.HEADING IW.USER.INFILE))
	    (if (EQ IW.CENTER.IMAGE (QUOTE YES))
		then (SETQ CENTER.DOWN (IMAX 0 (ITIMES (IQUOTIENT (IDIFFERENCE
									      
									 IMAGEWRITER.PAPER.LENGTH
									      (IQUOTIENT WIDTH 72))
									    2)
							       9)))
		       (for I from 1 to CENTER.DOWN
			  do (\IW.PRINT.CRLF)
			       (SETQ IW.PRINTLINECOUNT (ADD1 IW.PRINTLINECOUNT)))
		       (SETQ CENTER.LEFT (IQUOTIENT (IQUOTIENT (IDIFFERENCE 
									     IMAGEWRITER.BITWIDTH 
										    HEIGHT)
								     2)
							9))
		       (\IW.PRINTER.COMMAND (CHARCODE "L"))
		       (\IW.BOUT.PACK.NUM CENTER.LEFT 3))
	    (for COLUMN from OFFSET to 0 by -1
	       do (\IW.GRAPHICS.MODE HEIGHT)
		    (SETQ PTR COLUMN)
		    (for J from 1 to HEIGHT
		       do (BOUT IW.OUTSTREAM (\GETBASEBYTE BASE PTR))
			    (SETQ PTR (IPLUS PTR BYTESPERROW)))
		    (\IW.PRINT.CRLF)
		    (SETQ IW.PRINTLINECOUNT (ADD1 IW.PRINTLINECOUNT))
		    (BLOCK 1000))
	    (SETQ TEMPLINESPERPAGE (SETQ LINESPERPAGE (ITIMES IMAGEWRITER.PAPER.LENGTH 9)))
	TRYAGAIN
	    (if (LEQ (SETQ TABUP (IDIFFERENCE TEMPLINESPERPAGE IW.PRINTLINECOUNT))
			 0)
		then (SETQ TEMPLINESPERPAGE (IPLUS TEMPLINESPERPAGE LINESPERPAGE))
		       (GO TRYAGAIN))
	    (from 0 to TABUP do (\IW.PRINT.CRLF))
	    (\IW.PRINTER.MODE (QUOTE Reset))
	    (\IW.PRINTER.LINE.SPACING IMAGEWRITER.LINES.PER.INCH)
	    (\IW.PRINTER.LINES.PER.PAGE IMAGEWRITER.LINES.PER.PAGE)
	    (\IW.PRINTER.MODE (QUOTE UniDirectionalOff))
	    (CLEARW IW.DISPLAY)
	    (CENTERPRINTINREGION "IMAGEWRITER" NIL IW.DISPLAY])

(\IW.SIZE.BITMAP
  [LAMBDA (BITMAP)                                           (* DECLARATIONS: INTEGER)
                                                             (* edited: "14-Feb-86 08:26")

          (* This function will print out a window onto the Imagewriter printer using the RS232/TTY Port.
	  The image printed will either be printed straight across or rotated 90, depending on whether its width 
	  (accounting for the IW.ROTATE.IMAGE flag) fits into IMAGEWRITER.BITWIDTH columns.)


    (PROG ((SHAPECODE 0)
	     (WIDTH (BITMAPWIDTH BITMAP))
	     (HEIGHT (BITMAPHEIGHT BITMAP))
	     WIDTH.DIFF HEIGHT.DIFF)
	    (if (EQ IW.ROTATE.IMAGE (QUOTE NO))
		then (SETQ SHAPECODE 1))
	    (if (IGREATERP WIDTH IMAGEWRITER.BITWIDTH)
		then (SETQ SHAPECODE (IPLUS SHAPECODE 4))
		       (SETQ WIDTH.DIFF (IDIFFERENCE WIDTH IMAGEWRITER.BITWIDTH)))
	    (if (IGREATERP HEIGHT IMAGEWRITER.BITWIDTH)
		then (SETQ SHAPECODE (IPLUS SHAPECODE 8))
		       (SETQ HEIGHT.DIFF (IDIFFERENCE HEIGHT IMAGEWRITER.BITWIDTH)))
	    (SELECTQ SHAPECODE
		       ((0 4)
			 (SETQ IW.OUTPUT.BITMAP BITMAP)
			 (ADD.PROCESS (QUOTE (\IW.PRINT.BITMAP IW.OUTPUT.BITMAP))
					(QUOTE NAME)
					(QUOTE IMAGEWRITER.PRINTING)))
		       ((1 9)
			 (SETQ IW.OUTPUT.BITMAP (\IW.ROTATE.BITMAP.RIGHT BITMAP))
			 (ADD.PROCESS (QUOTE (\IW.PRINT.BITMAP IW.OUTPUT.BITMAP))
					(QUOTE NAME)
					(QUOTE IMAGEWRITER.PRINTING)))
		       ((5 8 12 13)
			 (\IW.BITMAP.ASK.CORRECTION SHAPECODE)
			 (if (NEQ IW.ALT.SELECTION (QUOTE ABORT))
			     then (SELECTQ IW.ALT.SELECTION
					       (ROTATE T)
					       (ROTATE.BITMAP (SETQ IW.OUTPUT.BITMAP (
								  \IW.ROTATE.BITMAP.RIGHT BITMAP)))
					       (LEFT.EDGE.TRIMMED (SETQ IW.OUTPUT.BITMAP
								    (BITMAPCREATE 
									     IMAGEWRITER.BITWIDTH 
										    HEIGHT))
								  (BITBLT BITMAP WIDTH.DIFF 0 
									    IW.OUTPUT.BITMAP 0 0 
									    IMAGEWRITER.BITWIDTH 
									    HEIGHT (QUOTE INPUT)
									    (QUOTE REPLACE))
								  (SETQ IW.OUTPUT.BITMAP
								    (\IW.ROTATE.BITMAP.RIGHT 
										 IW.OUTPUT.BITMAP)))
					       (RIGHT.EDGE.TRIMMED (SETQ IW.OUTPUT.BITMAP
								     (BITMAPCREATE 
									     IMAGEWRITER.BITWIDTH 
										     HEIGHT))
								   (BITBLT BITMAP 0 0 
									     IW.OUTPUT.BITMAP 0 0 
									     IMAGEWRITER.BITWIDTH 
									     HEIGHT (QUOTE INPUT)
									     (QUOTE REPLACE))
								   (SETQ IW.OUTPUT.BITMAP
								     (\IW.ROTATE.BITMAP.RIGHT
								       IW.OUTPUT.BITMAP)))
					       (TOP.EDGE.TRIMMED (SETQ IW.OUTPUT.BITMAP
								   (BITMAPCREATE WIDTH 
									     IMAGEWRITER.BITWIDTH))
								 (BITBLT BITMAP 0 0 
									   IW.OUTPUT.BITMAP 0 0 WIDTH 
									   IMAGEWRITER.BITWIDTH
									   (QUOTE INPUT)
									   (QUOTE REPLACE))
								 (SETQ IW.OUTPUT.BITMAP
								   (\IW.ROTATE.BITMAP.RIGHT 
										 IW.OUTPUT.BITMAP)))
					       (TRIM.TOP.EDGE (SETQ IW.OUTPUT.BITMAP
								(BITMAPCREATE WIDTH 
									     IMAGEWRITER.BITWIDTH))
							      (BITBLT BITMAP 0 0 IW.OUTPUT.BITMAP 0 
									0 WIDTH IMAGEWRITER.BITWIDTH
									(QUOTE INPUT)
									(QUOTE REPLACE)))
					       (BOTTOM.EDGE.TRIMMED (SETQ IW.OUTPUT.BITMAP
								      (BITMAPCREATE WIDTH 
									     IMAGEWRITER.BITWIDTH))
								    (BITBLT BITMAP 0 HEIGHT.DIFF 
									      IW.OUTPUT.BITMAP 0 0 
									      WIDTH 
									     IMAGEWRITER.BITWIDTH
									      (QUOTE INPUT)
									      (QUOTE REPLACE))
								    (SETQ IW.OUTPUT.BITMAP
								      (\IW.ROTATE.BITMAP.RIGHT
									IW.OUTPUT.BITMAP)))
					       (TRIM.BOTTOM.EDGE (SETQ IW.OUTPUT.BITMAP
								   (BITMAPCREATE WIDTH 
									     IMAGEWRITER.BITWIDTH))
								 (BITBLT BITMAP 0 HEIGHT.DIFF 
									   IW.OUTPUT.BITMAP 0 0 WIDTH 
									   IMAGEWRITER.BITWIDTH
									   (QUOTE INPUT)
									   (QUOTE REPLACE)))
					       (ROT.LEFT.EDGE.TRIMMED (SETQ IW.OUTPUT.BITMAP
									(BITMAPCREATE 
									     IMAGEWRITER.BITWIDTH 
											HEIGHT))
								      (BITBLT BITMAP WIDTH.DIFF 0 
										IW.OUTPUT.BITMAP 0 0 
									     IMAGEWRITER.BITWIDTH 
										HEIGHT (QUOTE
										  INPUT)
										(QUOTE REPLACE)))
					       (TRIM.LEFT.EDGE.ROTATE (SETQ IW.OUTPUT.BITMAP
									(BITMAPCREATE 
									     IMAGEWRITER.BITWIDTH 
											HEIGHT))
								      (BITBLT BITMAP WIDTH.DIFF 0 
										IW.OUTPUT.BITMAP 0 0 
									     IMAGEWRITER.BITWIDTH 
										HEIGHT (QUOTE
										  INPUT)
										(QUOTE REPLACE))
								      (SETQ IW.OUTPUT.BITMAP
									(\IW.ROTATE.BITMAP.RIGHT
									  IW.OUTPUT.BITMAP)))
					       (ROT.RIGHT.EDGE.TRIMMED (SETQ IW.OUTPUT.BITMAP
									 (BITMAPCREATE 
									     IMAGEWRITER.BITWIDTH 
											 HEIGHT))
								       (BITBLT BITMAP 0 0 
										 IW.OUTPUT.BITMAP 0 0 
									     IMAGEWRITER.BITWIDTH 
										 HEIGHT (QUOTE
										   INPUT)
										 (QUOTE REPLACE)))
					       (TRIM.RIGHT.EDGE.ROTATE (SETQ IW.OUTPUT.BITMAP
									 (BITMAPCREATE 
									     IMAGEWRITER.BITWIDTH 
											 HEIGHT))
								       (BITBLT BITMAP 0 0 
										 IW.OUTPUT.BITMAP 0 0 
									     IMAGEWRITER.BITWIDTH 
										 HEIGHT (QUOTE
										   INPUT)
										 (QUOTE REPLACE))
								       (SETQ IW.OUTPUT.BITMAP
									 (\IW.ROTATE.BITMAP.RIGHT
									   IW.OUTPUT.BITMAP)))
					       (ROT.TOP.EDGE.TRIMMED (SETQ IW.OUTPUT.BITMAP
								       (BITMAPCREATE WIDTH 
									     IMAGEWRITER.BITWIDTH))
								     (BITBLT BITMAP 0 0 
									       IW.OUTPUT.BITMAP 0 0 
									       WIDTH 
									     IMAGEWRITER.BITWIDTH
									       (QUOTE INPUT)
									       (QUOTE REPLACE)))
					       (ROT.BOTTOM.EDGE.TRIMMED (SETQ IW.OUTPUT.BITMAP
									  (BITMAPCREATE WIDTH 
									     IMAGEWRITER.BITWIDTH))
									(BITBLT BITMAP 0 
										  HEIGHT.DIFF 
										 IW.OUTPUT.BITMAP 0 0 
										  WIDTH 
									     IMAGEWRITER.BITWIDTH
										  (QUOTE INPUT)
										  (QUOTE REPLACE)))
					       (SHRINK (SETQ IW.OUTPUT.BITMAP
							 (SHRINKBITMAP BITMAP 2 2)))
					       (SHOULDNT)))
			 (IF (NEQ IW.ALT.SELECTION (QUOTE ABORT))
			     THEN (ADD.PROCESS (QUOTE (\IW.PRINT.BITMAP IW.OUTPUT.BITMAP))
						   (QUOTE NAME)
						   (QUOTE IMAGEWRITER.PRINTING))
			   ELSE (CLEARW IW.DISPLAY)
				  (CENTERPRINTREGION "IMAGEWRITER" NIL IW.DISPLAY)))
		       (SHOULDNT])

(\IW.BITMAP.ASK.CORRECTION
  [LAMBDA (SHAPECODE)                                        (* edited: "13-Feb-86 12:42")
    (PROG (ITEM.LIST USER.CORRECTION.MENU)
	    (SELECTQ SHAPECODE
		       [5 (SETQ ITEM.LIST (QUOTE (LEFT.EDGE.TRIMMED RIGHT.EDGE.TRIMMED ROTATE 
									SHRINK ABORT]
		       [8 (SETQ ITEM.LIST (QUOTE (TRIM.TOP.EDGE TRIM.BOTTOM.EDGE ROTATE.BITMAP 
								    SHRINK ABORT]
		       [12 (SETQ ITEM.LIST (QUOTE (TRIM.TOP.EDGE TRIM.BOTTOM.EDGE 
								     TRIM.LEFT.EDGE.ROTATE 
								     TRIM.RIGHT.EDGE.ROTATE SHRINK 
								     ABORT]
		       [13 (SETQ ITEM.LIST (QUOTE (LEFT.EDGE.TRIMMED RIGHT.EDGE.TRIMMED 
									 ROT.TOP.EDGE.TRIMMED 
									 ROT.BOTTOM.EDGE.TRIMMED 
									 SHRINK ABORT]
		       (SHOULDNT))
	    (SETQ USER.CORRECTION.MENU (create MENU
						   TITLE ← "Correction Option"
						   ITEMS ← ITEM.LIST
						   MENUOFFSET ←(QUOTE (242 . 50))
						   CHANGEOFFSETFLG ← T
						   MENUCOLUMNS ← 2
						   MENUBORDERSIZE ← 3
						   WHENSELECTEDFN ←(QUOTE \IW.SET.CORRECTION)
						   WHENHELDFN ←(QUOTE \IW.EXPLAIN.CORRECTION)
						   CENTERFLG ← T))
	    (RINGBELLS)
	    (PROMPTPRINT "Bitmap too big to fit on page as is. Please select an alternative")
	    (MENU USER.CORRECTION.MENU])

(\IW.SIZE.WINDOW
  [LAMBDA (WINDOW)                                           (* DECLARATIONS: INTEGER)
                                                             (* edited: "14-Feb-86 08:26")

          (* This function will print out a window onto the Imagewriter printer using the RS232/TTY Port.
	  The image printed will either be printed straight across or rotated 90, depending on whether its width 
	  (accounting for the NOROTATE? flag) fits into IMAGEWRITER.BITWIDTH columns.)


    (PROG ((SHAPECODE 0)
	     (WREGION (WINDOWPROP WINDOW (QUOTE REGION)))
	     (WBORDER (WINDOWPROP WINDOW (QUOTE BORDER)))
	     NOROTATE? LEFT BOTTOM WIDTH HEIGHT BITMAP)
	    (if (EQ IW.ROTATE.IMAGE (QUOTE NO))
		then (SETQ SHAPECODE 1)
		       (SETQ NOROTATE? T)
	      else (SETQ NOROTATE? NIL))
	    (if (IGREATERP (fetch (REGION WIDTH) of WREGION)
			       IMAGEWRITER.BITWIDTH)
		then (SETQ SHAPECODE (IPLUS SHAPECODE 4)))
	    (if (IGREATERP (fetch (REGION HEIGHT) of WREGION)
			       IMAGEWRITER.BITWIDTH)
		then (SETQ SHAPECODE (IPLUS SHAPECODE 8)))
	    (if (IGREATERP (WINDOWPROP WINDOW (QUOTE WIDTH))
			       IMAGEWRITER.BITWIDTH)
		then (SETQ SHAPECODE (IPLUS SHAPECODE 16)))
	    (if (IGREATERP (WINDOWPROP WINDOW (QUOTE HEIGHT))
			       IMAGEWRITER.BITWIDTH)
		then (SETQ SHAPECODE (IPLUS SHAPECODE 32)))
	    (SETQ LEFT (fetch (REGION LEFT) of WREGION))
	    (SETQ BOTTOM (fetch (REGION BOTTOM) of WREGION))
	    (SETQ WIDTH (fetch (REGION WIDTH) of WREGION))
	    (SETQ HEIGHT (fetch (REGION HEIGHT) of WREGION))
	    [if (EQ IW.PRINT.WINDOW.BORDERS (QUOTE YES))
		then (SETQ SHAPECODE (IPLUS SHAPECODE 2))
	      else (SETQ LEFT (IPLUS LEFT WBORDER))
		     (SETQ BOTTOM (IPLUS BOTTOM WBORDER))
		     (SETQ WIDTH (WINDOWPROP WINDOW (QUOTE WIDTH)))
		     (SETQ HEIGHT (WINDOWPROP WINDOW (QUOTE HEIGHT]
	    (SELECTQ SHAPECODE
		       ((0 1 2 3 4 5 6 8 9 11 12 13 20 22 28 41 43 45)
			 (SETQ BITMAP (BITMAPCREATE WIDTH HEIGHT 1))
			 (OPENW WINDOW)
			 (TOTOPW WINDOW)
			 (BITBLT (SCREENBITMAP)
				   LEFT BOTTOM BITMAP 0 0 WIDTH HEIGHT (QUOTE INPUT)
				   (QUOTE REPLACE))
			 (if NOROTATE?
			     then (SETQ BITMAP (\IW.ROTATE.BITMAP.RIGHT BITMAP)))
			 (SETQ IW.OUTPUT.BITMAP BITMAP)
			 (ADD.PROCESS (QUOTE (\IW.PRINT.BITMAP IW.OUTPUT.BITMAP))
					(QUOTE NAME)
					(QUOTE IMAGEWRITER.PRINTING)))
		       [(7 10 14 15 21 23 29 30 31 40 42 44 46 47 60 61 62 63)
			 (\IW.WINDOW.ASK.CORRECTION SHAPECODE)
			 (if (NEQ IW.ALT.SELECTION (QUOTE ABORT))
			     then (SELECTQ IW.ALT.SELECTION
					       (ROTATED.WINDOW (SETQ NOROTATE? NIL))
					       (NON-ROTATED.WINDOW (SETQ NOROTATE? T))
					       [R.BORDER.NOT.DISPLAYED (if (EQ 
									  IW.PRINT.WINDOW.BORDERS
										   (QUOTE YES))
									   then
									    (SETQ LEFT
									      (IPLUS LEFT WBORDER))
									    (SETQ BOTTOM
									      (IPLUS BOTTOM WBORDER)
									      )
									    (SETQ WIDTH
									      (WINDOWPROP
										WINDOW
										(QUOTE WIDTH)))
									    (SETQ HEIGHT
									      (WINDOWPROP
										WINDOW
										(QUOTE HEIGHT]
					       [NR.BORDER.NOT.DISPLAYED (if (EQ 
									  IW.PRINT.WINDOW.BORDERS
										    (QUOTE YES))
									    then
									     (SETQ LEFT
									       (IPLUS LEFT WBORDER))
									     (SETQ BOTTOM
									       (IPLUS BOTTOM 
											WBORDER))
									     (SETQ WIDTH
									       (WINDOWPROP
										 WINDOW
										 (QUOTE WIDTH)))
									     (SETQ HEIGHT
									       (WINDOWPROP
										 WINDOW
										 (QUOTE HEIGHT]
					       (TOP.EDGE.TRIMMED (SETQ NOROTATE? NIL)
								 (SETQ HEIGHT (IMIN HEIGHT 
									     IMAGEWRITER.BITWIDTH)))
					       (BOTTOM.EDGE.TRIMMED (SETQ NOROTATE? NIL)
								    [SETQ BOTTOM
								      (IPLUS BOTTOM HEIGHT
									       (IMINUS
										 (IMIN HEIGHT 
									     IMAGEWRITER.BITWIDTH]
								    (SETQ HEIGHT (IMIN HEIGHT 
									     IMAGEWRITER.BITWIDTH)))
					       (LEFT.EDGE.TRIMMED (SETQ NOROTATE? T)
								  [SETQ LEFT
								    (IPLUS LEFT WIDTH
									     (IMINUS (IMIN WIDTH 
									     IMAGEWRITER.BITWIDTH]
								  (SETQ WIDTH (IMIN WIDTH 
									     IMAGEWRITER.BITWIDTH)))
					       (RIGHT.EDGE.TRIMMED (SETQ NOROTATE? T)
								   (SETQ WIDTH (IMIN WIDTH 
									     IMAGEWRITER.BITWIDTH)))
					       (SHOULDNT))
				    (IF (NEQ IW.ALT.SELECTION (QUOTE ABORT))
					THEN (SETQ BITMAP (BITMAPCREATE WIDTH HEIGHT 1))
					       (OPENW WINDOW)
					       (TOTOPW WINDOW)
					       (BITBLT (SCREENBITMAP)
							 LEFT BOTTOM BITMAP 0 0 WIDTH HEIGHT
							 (QUOTE INPUT)
							 (QUOTE REPLACE))
					       (if NOROTATE?
						   then (SETQ BITMAP (\IW.ROTATE.BITMAP.RIGHT
							      BITMAP)))

          (* Because the function \GETBASEBYTE is much faster than BITMAPBIT, and can only work on bitmaps, first this 
	  function changes the window into a bitmap, then it performs functions upon the created bitmap as if it had been 
	  called from RS232.PRINT.)


					       (SETQ IW.OUTPUT.BITMAP BITMAP)
					       (ADD.PROCESS (QUOTE (\IW.PRINT.BITMAP 
										 IW.OUTPUT.BITMAP))
							      (QUOTE NAME)
							      (QUOTE IMAGEWRITER.PRINTING))
				      ELSE (CLEARW IW.DISPLAY)
					     (CENTERPRINTREGION "IMAGEWRITER" NIL IW.DISPLAY]
		       (SHOULDNT])

(\IW.WINDOW.ASK.CORRECTION
  [LAMBDA (SHAPECODE)                                        (* edited: "13-Feb-86 12:54")
    (PROG (ITEM.LIST USER.CORRECTION.MENU)
	    (SELECTQ SHAPECODE
		       [7 (SETQ ITEM.LIST (QUOTE (ROTATED.WINDOW NR.BORDER.NOT.DISPLAYED 
								     LEFT.EDGE.TRIMMED 
								     RIGHT.EDGE.TRIMMED ABORT]
		       [10 (SETQ ITEM.LIST (QUOTE (NON-ROTATED.WINDOW R.BORDER.NOT.DISPLAYED 
									  TOP.EDGE.TRIMMED 
									  BOTTOM.EDGE.TRIMMED ABORT]
		       [(14 15)
			 (SETQ ITEM.LIST (QUOTE (TOP.EDGE.TRIMMED BOTTOM.EDGE.TRIMMED 
								      LEFT.EDGE.TRIMMED 
								      RIGHT.EDGE.TRIMMED ABORT]
		       [(21 23 29)
			 (SETQ ITEM.LIST (QUOTE (ROTATED.WINDOW LEFT.EDGE.TRIMMED 
								    RIGHT.EDGE.TRIMMED ABORT]
		       [(30 31)
			 (SETQ ITEM.LIST (QUOTE (R.BORDER.NOT.DISPLAYED LEFT.EDGE.TRIMMED 
									    RIGHT.EDGE.TRIMMED 
									    TOP.EDGE.TRIMMED 
									    BOTTOM.EDGE.TRIMMED ABORT]
		       [(40 42 44)
			 (SETQ ITEM.LIST (QUOTE (NON-ROTATED.WINDOW TOP.EDGE.TRIMMED 
									BOTTOM.EDGE.TRIMMED ABORT]
		       [(46 47)
			 (SETQ ITEM.LIST (QUOTE (NR.BORDER.NOT.DISPLAYED TOP.EDGE.TRIMMED 
									     BOTTOM.EDGE.TRIMMED 
									     LEFT.EDGE.TRIMMED 
									     RIGHT.EDGE.TRIMMED ABORT]
		       [(60 61 62 63)
			 (SETQ ITEM.LIST (QUOTE (NR.BORDER.NOT.DISPLAYED TOP.EDGE.TRIMMED 
									     BOTTOM.EDGE.TRIMMED 
									     LEFT.EDGE.TRIMMED 
									     RIGHT.EDGE.TRIMMED ABORT]
		       (SHOULDNT))
	    (SETQ USER.CORRECTION.MENU (create MENU
						   TITLE ← "Correction Option"
						   ITEMS ← ITEM.LIST
						   MENUOFFSET ←(QUOTE (150 . 13))
						   CHANGEOFFSETFLG ← T
						   MENUCOLUMNS ← 2
						   MENUBORDERSIZE ← 3
						   WHENSELECTEDFN ←(QUOTE \IW.SET.CORRECTION)
						   WHENHELDFN ←(QUOTE \IW.EXPLAIN.CORRECTION)
						   CENTERFLG ← T))
	    (RINGBELLS)
	    (PROMPTPRINT "Window too big to fit in the page. Please select an alternative")
	    (MENU USER.CORRECTION.MENU])

(\IW.SET.CORRECTION
  [LAMBDA (OPTION)                                           (* edited: "13-Feb-86 12:40")
    (if (NOT OPTION)
	then (SETQ IW.ALT.SELECTION (QUOTE ABORT))
      else (SETQ IW.ALT.SELECTION OPTION])

(\IW.EXPLAIN.CORRECTION
  [LAMBDA (SELECTION)                                        (* edited: "12-Feb-86 16:05")
    (if (NOT SELECTION)
	then (SETQ SELECTION (QUOTE ABORT)))
    (SELECTQ SELECTION
	       (ROTATED.WINDOW (PROMPTPRINT "Rotate"))
	       (LEFT.EDGE.TRIMMED (PROMPTPRINT "Trim left edge"))
	       (RIGHT.EDGE.TRIMMED (PROMPTPRINT "Trim right edge"))
	       (NON-ROTATED.WINDOW (PROMPTPRINT "Non-rotated window"))
	       (TOP.EDGE.TRIMMED (PROMPTPRINT "Top edge trimmed"))
	       (BOTTOM.EDGE.TRIMMED (PROMPTPRINT "Bottom edge trimmed"))
	       (NR.BORDER.NOT.DISPLAYED (PROMPTPRINT 
					       "Window border not displayed (Non-rotated window)"))
	       (R.BORDER.NOT.DISPLAYED (PROMPTPRINT "Window border not displayed (Rotated window) ")
				       )
	       (ROTATE.BITMAP (PROMPTPRINT "Rotate the bitmap"))
	       (TRIM.TOP.EDGE (PROMPTPRINT "Trim top edge"))
	       (BOTTOM.EDGE.TRIMMED (PROMPTPRINT "Trim bottom edge"))
	       (TRIM.BOTTOM.EDGE (PROMPTPRINT "Trim bottom edge"))
	       (ROT.LEFT.EDGE.TRIMMED (PROMPTPRINT "Rotate and trim left edge"))
	       (TRIM.LEFT.EDGE.ROTATE (PROMPTPRINT "Rotate and trim left edge"))
	       (ROT.RIGHT.EDGE.TRIMMED (PROMPTPRINT "Rotate and trim right edge"))
	       (TRIM.RIGHT.EDGE.ROTATE (PROMPTPRINT "Rotate and trim right edge"))
	       (ROT.TOP.EDGE.TRIMMED (PROMPTPRINT "Rotate and trim top edge"))
	       (ROT.BOTTOM.EDGE.TRIMMED (PROMPTPRINT "Rotate and trim bottom edge"))
	       (SHRINK (PROMPTPRINT "Shrink bitmap in half"))
	       (ABORT (PROMPTPRINT "Abort this printing command"))
	       (SHOULDNT])

(\IW.ROTATE.BITMAP.RIGHT
  [LAMBDA (BITMAP)                                           (* HK "12-JUL-82 11:50")
    (PROG (NEW.BITMAP (WIDTH (fetch (BITMAP BITMAPWIDTH) of BITMAP))
			(HEIGHT (fetch (BITMAP BITMAPHEIGHT) of BITMAP)))
	    (SETQ NEW.BITMAP (BITMAPCREATE HEIGHT WIDTH))
	    [for X from 0 to (SUB1 WIDTH) do (for Y from 0 to (SUB1 HEIGHT)
							  bind (X1 ←(IDIFFERENCE (SUB1 WIDTH)
										     X))
							  do (BITMAPBIT NEW.BITMAP Y X1
									    (BITMAPBIT BITMAP X Y]
	    (RETURN NEW.BITMAP])
)



(* These functions create and implement menu operations)

(DEFINEQ

(\IW.INIT.TITLE
  [LAMBDA NIL                                                (* edited: "13-Feb-86 11:13")
    (PROG (TITLE.MENU)
	    (SETQ TITLE.MENU (create MENU
					 TITLE ← "SET TITLE FLAG"
					 ITEMS ←(QUOTE (YES NO))
					 MENUOFFSET ←(QUOTE (18 . 10))
					 MENUBORDERSIZE ← 2
					 CHANGEOFFSETFLG ← T
					 WHENSELECTEDFN ←(QUOTE \IW.SET.TITLE)
					 WHENHELDFN ←(QUOTE \IW.EXPLAIN.TITLE)
					 CENTERFLG ← T))
	    (MENU TITLE.MENU])

(\IW.EXPLAIN.TITLE
  [LAMBDA (ITEM)                                             (* edited: "27-Jan-86 09:02")
    (SELECTQ ITEM
	       (YES (PROMPTPRINT "Print title at top of first page"))
	       (NO (PROMPTPRINT "Do not print title on page"))
	       (SHOULDNT])

(\IW.SET.TITLE
  [LAMBDA (ITEM)                                             (* edited: "13-Feb-86 11:10")
    (if (EQ ITEM (QUOTE YES))
	then (SETQ IW.PRINT.TITLE (QUOTE YES))
      else (SETQ IW.PRINT.TITLE (QUOTE NO])

(\IW.INIT.CUSTOM.FONT
  [LAMBDA NIL                                                (* edited: "13-Feb-86 11:17")
    (PROG (FONT.MENU)
	    (SETQ FONT.MENU (create MENU
					TITLE ← "SET CUSTOM FONT FLAG"
					ITEMS ←(QUOTE (YES NO))
					MENUOFFSET ←(QUOTE (21 . 10))
					MENUBORDERSIZE ← 2
					CHANGEOFFSETFLG ← T
					WHENSELECTEDFN ←(QUOTE \IW.SET.CUSTOM.FONT.FLG)
					WHENHELDFN ←(QUOTE \IW.EXPLAIN.CUSTOM.FONT.FLG)
					CENTERFLG ← T))
	    (MENU FONT.MENU])

(\IW.SET.CUSTOM.FONT.FLG
  [LAMBDA (OPTION)                                           (* edited: "13-Feb-86 11:16")
    (if (EQ OPTION (QUOTE YES))
	then (SETQ IW.LOAD.CUSTOM.FONT (QUOTE YES))
      else (SETQ IW.LOAD.CUSTOM.FONT (QUOTE NO])

(\IW.EXPLAIN.CUSTOM.FONT.FLG
  [LAMBDA (ITEM)                                             (* edited: " 4-Feb-86 09:23")
    (SELECTQ ITEM
	       (YES (PROMPTPRINT "Use custom font to be loaded into the printer"))
	       (NO (PROMPTPRINT "Use standard font loaded in printer"))
	       (SHOULDNT])

(\IW.INIT.CENTER.FLG
  [LAMBDA NIL                                                (* edited: "13-Feb-86 11:22")
    (PROG (CENTER.MENU)
	    (SETQ CENTER.MENU (create MENU
					  TITLE ← "SET CENTER FLAG"
					  ITEMS ←(QUOTE (YES NO))
					  MENUOFFSET ←(QUOTE (71 . 8))
					  MENUBORDERSIZE ← 2
					  CHANGEOFFSETFLG ← T
					  WHENSELECTEDFN ←(QUOTE \IW.SET.CENTER.FLG)
					  WHENHELDFN ←(QUOTE \IW.EXPLAIN.CENTER)
					  CENTERFLG ← T))
	    (MENU CENTER.MENU])

(\IW.EXPLAIN.CENTER
  [LAMBDA (ITEM)                                             (* edited: "23-Aug-85 11:39")
    (SELECTQ ITEM
	       (YES (PROMPTPRINT "Your bitmap/window will be placed in the center of the page"))
	       (NO (PROMPTPRINT "Do not center my bitmap/window"))
	       (SHOULDNT])

(\IW.SET.CENTER.FLG
  [LAMBDA (OPTION)                                           (* edited: "13-Feb-86 11:22")
    (if (EQ OPTION (QUOTE YES))
	then (SETQ IW.CENTER.IMAGE (QUOTE YES))
      else (SETQ IW.CENTER.IMAGE (QUOTE NO])

(\IW.INIT.ROTATE.FLG
  [LAMBDA NIL                                                (* edited: "13-Feb-86 11:20")
    (PROG (ROTATE.MENU)
	    (SETQ ROTATE.MENU (create MENU
					  ITEMS ←(QUOTE (YES NO))
					  TITLE ← "ROTATE WINDOW?"
					  CENTERFLG ← T
					  MENUOFFSET ←(QUOTE (82 . 10))
					  CHANGEOFFSETFLG ← T
					  WHENSELECTEDFN ←(QUOTE \IW.SET.ROTATE.FLG)
					  WHENHELDFN ←(QUOTE \IW.EXPLAIN.ROTATE)))
	    (MENU ROTATE.MENU])

(\IW.EXPLAIN.ROTATE
  [LAMBDA (OPTION)                                           (* edited: "21-Aug-85 11:18")
    (SELECTQ OPTION
	       (YES (PROMPTPRINT "Rotate picture by +90 degree for a faster printing out"))
	       (NO (PROMPTPRINT 
		"Print it as it is even though it is going to be slower than the rotated version"))
	       (SHOULDNT])

(\IW.SET.ROTATE.FLG
  [LAMBDA (OPTION)                                           (* edited: "13-Feb-86 11:19")
    (if (EQ OPTION (QUOTE YES))
	then (SETQ IW.ROTATE.IMAGE (QUOTE YES))
      else (SETQ IW.ROTATE.IMAGE (QUOTE NO])

(\IW.INIT.SPEED
  [LAMBDA NIL                                                (* edited: "13-Feb-86 11:09")
    (PROG (SPEED.MENU)
	    (SETQ SPEED.MENU (create MENU
					 ITEMS ←(QUOTE (300 1200 2400 9600))
					 TITLE ← "BAUDREATE"
					 CENTERFLG ← T
					 MENUOFFSET ←(QUOTE (44 . 2))
					 CHANGEOFFSETFLG ← T
					 WHENSELECTEDFN ←(QUOTE \IW.SET.SPEED)
					 WHENHELDFN ←(QUOTE \IW.EXPLAIN.SPEED)))
	    (MENU SPEED.MENU])

(\IW.EXPLAIN.SPEED
  [LAMBDA (OPTION)                                           (* edited: "13-Feb-86 11:09")
    (PROMPTPRINT 
"Select the desired baud rate for printing (Default speed is 9600 BAUD).  Make sure your printer is set to the same speed"
		   ])

(\IW.SET.SPEED
  [LAMBDA (BAUD)                                             (* edited: "13-Feb-86 11:08")
    (PROG NIL
	    (SETQ IMAGEWRITER.BAUD.RATE BAUD])
)



(* These functions setup the printer modes)

(DEFINEQ

(\IW.BOUT.PACK.NUM
  [LAMBDA (NUM PLENGTH)                                      (* edited: " 4-Feb-86 09:28")

          (* Puts out a number (NUM) that is to occupy a certain length (PLENGTH). If the number is not of the correct length
	  0s are placed in front of it. (E.G. if NUM=3 and PLENGTH=4 the output will be "0003"))


    (PROG (UNPACK.NUM NUM.LENGTH PACK0 CHAR ZERO)
	    (SETQ UNPACK.NUM (UNPACK NUM))
	    (SETQ NUM.LENGTH (LENGTH UNPACK.NUM))
	    (SETQ PACK0 (IDIFFERENCE PLENGTH NUM.LENGTH))
	    [if (LEQ PACK0 0)
		then (for CHAR from 1 to NUM.LENGTH
			  do (BOUT IW.OUTSTREAM (NTHCHARCODE (MKSTRING (CAR UNPACK.NUM)
									       T)
								   1))
			       (SETQ UNPACK.NUM (CDR UNPACK.NUM)))
	      else (for ZERO from 1 to PACK0 do (BOUT IW.OUTSTREAM (CHARCODE "0")))
		     (for CHAR from 1 to NUM.LENGTH
			do (BOUT IW.OUTSTREAM (NTHCHARCODE (MKSTRING (CAR UNPACK.NUM)
									     T)
								 1))
			     (SETQ UNPACK.NUM (CDR UNPACK.NUM]
	    (FORCEOUTPUT IW.OUTSTREAM])

(\IW.STANDARD.MODE
  [LAMBDA NIL                                                (* edited: "13-Feb-86 12:01")

          (* Turn off all the previous switches, i.e., print in standard PITCH (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.))


    (PRIN1 IW.LINEBUFFER IW.OUTSTREAM)
    (SETQ IW.LINEBUFFER "")
    (\IW.PRINTER.MODE (QUOTE BoldOff))
    (\IW.PRINTER.MODE (QUOTE StopUnderLining))
    (\IW.PRINTER.MODE (QUOTE StopHeadlining))
    (\IW.PRINTER.MODE IMAGEWRITER.CHAR.PITCH)
    (\IW.PRINTER.MODE (QUOTE UniDirectionalOff))
    (\IW.PRINTER.COMMAND (CHARCODE "L"))
    (\IW.BOUT.PACK.NUM IMAGEWRITER.LMARGIN 3])

(\IW.GRAPHICS.MODE
  [LAMBDA (ROWS)                                             (* edited: "13-Feb-86 12:04")
    (\IW.PRINTER.COMMAND (CHARCODE "G"))
    (FORCEOUTPUT IW.OUTSTREAM)
    (\IW.BOUT.PACK.NUM ROWS 4])

(\IW.BOLD.MODE
  [LAMBDA NIL                                                (* edited: "13-Feb-86 11:57")
                                                             (* Print Bold pitch)
    (PRIN1 IW.LINEBUFFER IW.OUTSTREAM)
    (SETQ IW.LINEBUFFER "")
    (\IW.PRINTER.MODE (QUOTE BoldOn])

(\IW.COMMENT.MODE
  [LAMBDA NIL                                                (* edited: "13-Feb-86 11:58")
                                                             (* Print in superscripted, italicized, compressed 
							     pitch)
    (PRIN1 IW.LINEBUFFER IW.OUTSTREAM)
    (SETQ IW.LINEBUFFER "")
    (\IW.PRINTER.MODE (QUOTE Condensed])

(\IW.EXPANDED.MODE
  [LAMBDA NIL                                                (* edited: "13-Feb-86 11:59")
                                                             (* Print in Expanded pitch)
    (PRIN1 IW.LINEBUFFER IW.OUTSTREAM)
    (SETQ IW.LINEBUFFER "")
    (\IW.PRINTER.MODE (QUOTE StartHeadlining])

(\IW.PRINT.TEXT.INIT
  [LAMBDA NIL                                                (* edited: "15-Feb-86 12:51")
                                                             (* Perform all of the initialization, including 
							     setting the character modes for appropriate pitch, and
							     making sure that XON\XOFF protocol is used.)
    (\IW.PRINTER.MODE (QUOTE Reset))
    (\IW.PRINTER.MODE IMAGEWRITER.CHAR.PITCH)
    (\IW.PRINTER.MODE (QUOTE UniDirectionalOff))
    (\IW.PRINTER.LINES.PER.PAGE IMAGEWRITER.LINES.PER.PAGE)
    (\IW.PRINTER.LINE.SPACING IMAGEWRITER.LINES.PER.INCH)
    (\IW.PRINTER.COMMAND (CHARCODE "L"))
    (\IW.BOUT.PACK.NUM IMAGEWRITER.LMARGIN 3])

(\IW.PRINTER.LINES.PER.PAGE
  [LAMBDA (LPP)                                              (* edited: "14-Feb-86 08:27")
                                                             (* SET TOP OF FORM)
    (BOUT IW.OUTSTREAM 29)
    (BOUT IW.OUTSTREAM 65)
    (BOUT IW.OUTSTREAM 64)                                 (* SETS NO TAB CODES)
    (for I from 1 to (IDIFFERENCE LPP 2)
       do (BOUT IW.OUTSTREAM 64)
	    (BOUT IW.OUTSTREAM 64))                        (* SET BOTTOM OF FORM)
    (BOUT IW.OUTSTREAM 67)
    (BOUT IW.OUTSTREAM 64)                                 (* FILLS IN REMAINDER OF PAGE)
    (for I from 1 to (IDIFFERENCE (ITIMES IMAGEWRITER.PAPER.LENGTH 
						    IMAGEWRITER.LINES.PER.INCH)
					  LPP)
       do (BOUT IW.OUTSTREAM 64)
	    (BOUT IW.OUTSTREAM 64))                        (* SETS TOP OF FORM NEXT FORM)
    (BOUT IW.OUTSTREAM 65)
    (BOUT IW.OUTSTREAM 64)
    (BOUT IW.OUTSTREAM 30)
    (FORCEOUTPUT IW.OUTSTREAM])

(\IW.PRINTER.LINE.SPACING
  [LAMBDA (LPI)                                              (* edited: "13-Feb-86 13:06")
    (if (LEQ LPI 2)
	then (SETQ LPI 2))
    (BOUT IW.OUTSTREAM (CHARCODE ESC))
    (BOUT IW.OUTSTREAM (CHARCODE "T"))
    (\IW.BOUT.PACK.NUM (FIX (QUOTIENT 144 LPI))
			 2])

(\IW.PRINT.HEADING
  [LAMBDA (FILENAME)                                         (* edited: "13-Feb-86 13:53")
    (if (EQ IMAGEWRITER.PORT (QUOTE RS232C))
	then (\IW.PRINT.CRLF)
      else (\IW.PRINT.CR))
    (\IW.PRINTER.MODE (QUOTE BoldOn))
    (PRIN1 "Printout of " IW.OUTSTREAM)
    (PRIN1 FILENAME IW.OUTSTREAM)
    (PRIN1 " , " IW.OUTSTREAM)
    (PRIN1 (DATE)
	     IW.OUTSTREAM)
    (PRIN1 " by " IW.OUTSTREAM)
    (PRIN1 USERNAME IW.OUTSTREAM)
    (if (EQ IMAGEWRITER.PORT (QUOTE RS232C))
	then (\IW.PRINT.CRLF)
      else (\IW.PRINT.CR))
    (\IW.PRINTER.MODE (QUOTE BoldOff))
    (\IW.PRINT.CRLF)
    (if (EQ IMAGEWRITER.PORT (QUOTE RS232C))
	then (\IW.PRINT.CRLF)
      else (\IW.PRINT.CR])

(\IW.PRINTER.COMMAND
  [LAMBDA (CommandChar)                                      (* edited: "29-Jan-86 15:25")

          (* 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.)


    (BOUT IW.OUTSTREAM (CHARCODE ESC))
    (BOUT IW.OUTSTREAM CommandChar)
    (FORCEOUTPUT IW.OUTSTREAM])

(\IW.PRINT.CRLF
  [LAMBDA NIL                                                (* edited: "24-Jan-86 08:02")
                                                             (* Send a carraige return/line feed to the printer;
							     the printer holds all incoming characters in its 
							     buffer until it sees a CR/LF.)
    (BOUT IW.OUTSTREAM (CHARCODE CR))
    (BOUT IW.OUTSTREAM (CHARCODE LF))
    (FORCEOUTPUT IW.OUTSTREAM])

(\IW.PRINT.CR
  [LAMBDA NIL                                                (* edited: " 6-Feb-86 14:16")
    (BOUT IW.OUTSTREAM (CHARCODE CR))
    (FORCEOUTPUT IW.OUTSTREAM])

(\IW.PRINTER.MODE
  [LAMBDA (Mode)                                             (* edited: "14-Feb-86 08:27")

          (* Ths function takes as its argument the mode for the printer to print in, and sends this to the printer via the 
	  function \IW.PRINTER.COMMAND)


    (SELECTQ Mode
	       (Reset (\IW.PRINTER.COMMAND (CHARCODE "c")))
	       (ResetTabTOF (BOUT IW.OUTSTREAM 29)
			    (BOUT IW.OUTSTREAM 48)
			    (FORCEOUTPUT IW.OUTSTREAM))
	       (ClearBuffer (BOUT IW.OUTSTREAM 24)
			    (FORCEOUTPUT IW.OUTSTREAM))
	       (BoldOn (\IW.PRINTER.COMMAND (CHARCODE "!")))
	       (BoldOff (\IW.PRINTER.COMMAND (CHARCODE %")))
	       (Extended (\IW.PRINTER.COMMAND (CHARCODE "n")))
	       (Pica (\IW.PRINTER.COMMAND (CHARCODE "N")))
	       (Elite (\IW.PRINTER.COMMAND (CHARCODE "E")))
	       (EliteProportional (\IW.PRINTER.COMMAND (CHARCODE "P")))
	       (PicaProportional (\IW.PRINTER.COMMAND (CHARCODE "p")))
	       (Semicondensed (\IW.PRINTER.COMMAND (CHARCODE "e")))
	       (Condensed (\IW.PRINTER.COMMAND (CHARCODE "q")))
	       (Ultracondensed (\IW.PRINTER.COMMAND (CHARCODE "Q")))
	       (StartUnderLining (\IW.PRINTER.COMMAND (CHARCODE "X")))
	       (StopUnderLining (\IW.PRINTER.COMMAND (CHARCODE "Y")))
	       (StartHeadlining (BOUT IW.OUTSTREAM 14)
				(FORCEOUTPUT IW.OUTSTREAM))
	       (StopHeadlining (BOUT IW.OUTSTREAM 15)
			       (FORCEOUTPUT IW.OUTSTREAM))
	       (UniDirectionalOn (\IW.PRINTER.COMMAND (CHARCODE ">")))
	       (UniDirectionalOff (\IW.PRINTER.COMMAND (CHARCODE "<")))
	       (SixSpacingOn (\IW.PRINTER.COMMAND (CHARCODE "A")))
	       (SevenSpacingOn (\IW.PRINTER.COMMAND (CHARCODE "T"))
			       (\IW.BOUT.PACK.NUM 20 0))
	       (EightSpacingOn (\IW.PRINTER.COMMAND (CHARCODE "B")))
	       (NineSpacingOn (\IW.PRINTER.COMMAND (CHARCODE "T"))
			      (\IW.BOUT.PACK.NUM 16 0))
	       (TwelveSpacingOn (\IW.PRINTER.COMMAND (CHARCODE "T"))
				(\IW.BOUT.PACK.NUM 12 0))
	       (GraphicSpacingOn (\IW.PRINTER.COMMAND (CHARCODE "T"))
				 (\IW.BOUT.PACK.NUM 16 0))
	       (SHOULDNT])
)

(RPAQ? IMAGEWRITER.PORT (QUOTE RS232C))

(RPAQ? IMAGEWRITER.PROTOCOL (QUOTE XOnXOff))

(RPAQ? IMAGEWRITER.BAUD.RATE 9600)

(RPAQ? IMAGEWRITER.PAPER.LENGTH 11)

(RPAQ? IMAGEWRITER.LINES.PER.PAGE 60)

(RPAQ? IMAGEWRITER.LINES.PER.INCH 6)

(RPAQ? IMAGEWRITER.LMARGIN 3)

(RPAQ? IMAGEWRITER.RMARGIN 96)

(RPAQ? IMAGEWRITER.CHAR.PITCH (QUOTE Elite))

(RPAQ? IMAGEWRITER.BITWIDTH 576)

(RPAQ? IW.PRINT.TITLE (QUOTE NO))

(RPAQ? IW.CENTER.IMAGE (QUOTE NO))

(RPAQ? IW.ROTATE.IMAGE (QUOTE YES))

(RPAQ? IW.PRINT.WINDOW.BORDERS (QUOTE YES))

(RPAQ? IW.LOAD.CUSTOM.FONT (QUOTE NO))

(RPAQ? IW.CUSTOM.FONT.FILENAME (QUOTE NONE))

(RPAQ? IW.OUTSTREAM NIL)

(RPAQ? IW.RS232PORT.STREAM NIL)

(RPAQ? IW.TTYPORT.STREAM NIL)
(DECLARE: DOEVAL@COMPILE DONTCOPY

(GLOBALVARS IW.DISPLAY IW.MENU.WINDOW IW.WINDOW IW.DEFAULT.SELECT.MENUWINDOW IW.INPUT.FILE 
	    IW.USER.INFILE IMAGEWRITER.PORT IMAGEWRITER.BAUD.RATE IMAGEWRITER.PROTOCOL 
	    IMAGEWRITER.PAPER.LENGTH IMAGEWRITER.LINES.PER.PAGE IMAGEWRITER.CHAR.PITCH 
	    IMAGEWRITER.BITWIDTH IMAGEWRITER.LMARGIN IMAGEWRITER.RMARGIN IW.PRINT.TITLE 
	    IW.CENTER.IMAGE IW.ROTATE.IMAGE IW.PRINT.WINDOW.BORDERS IW.LOAD.CUSTOM.FONT 
	    IW.CUSTOM.FONT.FILENAME IMAGEWRITER.LINE.LENGTH IW.PRINTLINECOUNT IW.OUTSTREAM 
	    IW.RS232PORT.STREAM IW.TTYPORT.STREAM IW.LINEBUFFER IW.CHAR.COUNT IW.INPUT.CHAR 
	    IW.OUTPUT.BITMAP IW.ALT.SELECTION)
)
(PUTPROPS IMAGEWRITER COPYRIGHT ("XEROX Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (7508 22599 (IMAGEWRITER.START 7518 . 9095) (IMAGEWRITER 9097 . 12348) (
\IW.EXPLAIN.OPTIONS 12350 . 12795) (\IW.FILE.ERRORCHECK 12797 . 13675) (\IW.INIT.PORT 13677 . 14763) (
\IW.DEFAULTS.MENU 14765 . 18107) (\IW.SET.DEFAULTS 18109 . 19757) (\IW.SHOW.DEFAULTS 19759 . 22253) (
\IW.QUIT.OPTION 22255 . 22597)) (22664 49400 (\IW.PRINT.FILE 22674 . 23123) (\IW.PRINT.TEXT 23125 . 
25133) (\IW.SELECT.PRINTER.MODE 25135 . 26043) (\IW.PRINT.CHAR 26045 . 27540) (\IW.PRINT.BITMAP 27542
 . 30424) (\IW.SIZE.BITMAP 30426 . 37349) (\IW.BITMAP.ASK.CORRECTION 37351 . 38685) (\IW.SIZE.WINDOW 
38687 . 44706) (\IW.WINDOW.ASK.CORRECTION 44708 . 46809) (\IW.SET.CORRECTION 46811 . 47065) (
\IW.EXPLAIN.CORRECTION 47067 . 48779) (\IW.ROTATE.BITMAP.RIGHT 48781 . 49398)) (49466 54798 (
\IW.INIT.TITLE 49476 . 49962) (\IW.EXPLAIN.TITLE 49964 . 50254) (\IW.SET.TITLE 50256 . 50519) (
\IW.INIT.CUSTOM.FONT 50521 . 51028) (\IW.SET.CUSTOM.FONT.FLG 51030 . 51315) (
\IW.EXPLAIN.CUSTOM.FONT.FLG 51317 . 51639) (\IW.INIT.CENTER.FLG 51641 . 52149) (\IW.EXPLAIN.CENTER 
52151 . 52473) (\IW.SET.CENTER.FLG 52475 . 52747) (\IW.INIT.ROTATE.FLG 52749 . 53231) (
\IW.EXPLAIN.ROTATE 53233 . 53604) (\IW.SET.ROTATE.FLG 53606 . 53878) (\IW.INIT.SPEED 53880 . 54347) (
\IW.EXPLAIN.SPEED 54349 . 54619) (\IW.SET.SPEED 54621 . 54796)) (54851 64545 (\IW.BOUT.PACK.NUM 54861
 . 56030) (\IW.STANDARD.MODE 56032 . 56889) (\IW.GRAPHICS.MODE 56891 . 57128) (\IW.BOLD.MODE 57130 . 
57450) (\IW.COMMENT.MODE 57452 . 57831) (\IW.EXPANDED.MODE 57833 . 58173) (\IW.PRINT.TEXT.INIT 58175
 . 58918) (\IW.PRINTER.LINES.PER.PAGE 58920 . 59991) (\IW.PRINTER.LINE.SPACING 59993 . 60335) (
\IW.PRINT.HEADING 60337 . 61178) (\IW.PRINTER.COMMAND 61180 . 61580) (\IW.PRINT.CRLF 61582 . 62054) (
\IW.PRINT.CR 62056 . 62250) (\IW.PRINTER.MODE 62252 . 64543)))))
STOP