(DEFINE-FILE-INFO PACKAGE "INTERLISP" READTABLE "INTERLISP" BASE 10) (FILECREATED " 1-Feb-2022 16:50:25"  {DSK}kaplan>Local>medley3.5>my-medley>lispusers>MULTIPLE-HARDCOPY.;2 10662 :CHANGES-TO (FNS TOC) :PREVIOUS-DATE "22-Aug-86 12:23:34" {DSK}kaplan>Local>medley3.5>my-medley>lispusers>MULTIPLE-HARDCOPY.;1) (PRETTYCOMPRINT MULTIPLE-HARDCOPYCOMS) (RPAQQ MULTIPLE-HARDCOPYCOMS [(FNS MH.GET.INPUT.FILE MH.MAKE.GLOSSARY MULTIPLE.HARDCOPY MH.SET.STARTINGPAGE# MH.GET.PAGE# TOC) (P (TEDIT.ADD.MENUITEM TEDIT.DEFAULT.MENU '(MULTIPLE% HARDCOPY 'MULTIPLE.HARDCOPY "HARDCOPY A LIST OF FILES." ]) (DEFINEQ (MH.GET.INPUT.FILE [LAMBDA (FILE) (* edited%: "22-Aug-86 12:11") (* Returns the file if the file is accessible or otherwise pesters the unwitting  user until an existing file is supplied or nil to abort) (PROG NIL LOOP (OR FILE (RETURN)) (AND (INFILEP FILE) (RETURN FILE)) (printout T (CONCAT FILE " [not found.] ") T "TYPE ANOTHER INPUT FILE (NIL TO ABORT): ") (SETQ FILE (READ T)) (OR FILE (RETURN)) (GO LOOP]) (MH.MAKE.GLOSSARY [LAMBDA (FILENAME) (* edited%: "22-Aug-86 12:14") (* This function relies on the function TOC  (written by Nick Briggs) to produce a table of contents.  It just takes the TEdit stream returned by TOC and TEDIT.PUTs it to a file.) (COND ((BOUNDP 'MULTIPLE.HARDCOPY.LIST) (TEDIT.PUT (TOC MULTIPLE.HARDCOPY.LIST) FILENAME)) (T (PRINTOUT T "MULTIPLE.HARDCOPY MUST BE RUN FIRST" T]) (MULTIPLE.HARDCOPY [LAMBDA (STREAM FILELST GLOSSARY.FILE TOFILE? DONTSEND UNFORMATTED? BREAKPAGETITLE SERVER PRINTOPTIONS) (* edited%: "22-Aug-86 12:23") (* HARDCOPIES all the files in FILELST making sure that the files are numbered  consecutively. If STREAM is supplied then it should be a TEdit stream.  The intent is that one could set up one's desired page looks in a TEdit window  and then pass that TEdit stream to MULTIPLE.HARDCOPY which will use those page  looks. If a STREAM is not given then a fresh TEdit window is started.  FILELST should be a list of files to hardcopy in the order that they should be  numbered. GLOSSARY.FILE, if given, should be the name of a file.  If given then after MULTIPLE.HARDCOPY is done hardcopying it will use the  MH.MAKE.GLOSSARY to make a table of contents for the files and save the table of  contents in GLOSSARY.FILE. If TOFILE? is NON-NIL then an IP file will be created  for each file in FILELST that is the same name as the file but with extension IP.  If DONTSEND is NON-NIL then the files will not be sent to the printer  (this only makes sense if you're creating IP files)%.  If UNFORMATTED? is NON-NIL then the files will be hardcopied without formatting  information. BREAKPAGETITLE, SERVER and PRINTOPTIONS are the same as per  TEDIT.HARDCOPY. After MULTIPLE.HARDCOPY is done, it returns a variable  MULTIPLE.HARDCOPY.LIST which is a useful list of information about this hardcopy  process. The list is of the form%: ( %.  ) where each pair is of the form  ( )) (PROG* (FRAME LOCALINFO INITIAL.DEFAULTPG PG) (OR FILELST (SETQ FILELST (TTYIN "FILELST TO HARDCOPY>>")) (RETURN (PRINTOUT T "No filelst specified."))) [OR STREAM (SETQ STREAM (TEXTSTREAM (PROCESSPROP (TEDIT (MH.GET.INPUT.FILE (CAR FILELST))) 'WINDOW] (COND ((ATOM FILELST) (SETQ FILELST (LIST FILELST))) (FILELST)) (SETQ FRAME (OR (fetch TXTPAGEFRAMES of (TEXTOBJ STREAM)) TEDIT.PAGE.FRAMES)) [SETQ LOCALINFO (fetch REGIONLOCALINFO of (COND ((LISTP FRAME) (CAR FRAME)) (T FRAME] [SETQ INITIAL.DEFAULTPG (AND (LISTGET LOCALINFO 'STARTINGPAGE#) (SUB1 (LISTGET LOCALINFO 'STARTINGPAGE#] (SETQ PG (OR INITIAL.DEFAULTPG 0)) (SETQ MULTIPLE.HARDCOPY.LIST NIL) (ADVISE 'TEDIT.PROMPTPRINT 'BEFORE '(SETQ PG MSG)) [for FILE in FILELST do (PROGN (SETQ FILE (MH.GET.INPUT.FILE FILE)) (OR FILE (RETURN)) (PROMPTPRINT "MULTIPLE.HARDCOPY: " (FULLNAME FILE)) (TEDIT.GET (TEXTOBJ STREAM) FILE UNFORMATTED?) (replace TXTPAGEFRAMES of (TEXTOBJ STREAM) with FRAME) (MH.SET.STARTINGPAGE# (ADD1 PG) FRAME) (TEDIT.HARDCOPY STREAM (COND (TOFILE? (PACKFILENAME 'NAME TOFILE? 'EXTENSION 'IP)) (T NIL)) DONTSEND BREAKPAGETITLE SERVER PRINTOPTIONS) (SETQ PG (MKATOM (MH.GET.PAGE# PG))) (SETQ MULTIPLE.HARDCOPY.LIST (NCONC1 MULTIPLE.HARDCOPY.LIST (CONS FILE PG] (UNADVISE TEDIT.PROMPTPRINT) (MH.SET.STARTINGPAGE# (AND INITIAL.DEFAULTPG (ADD1 INITIAL.DEFAULTPG)) FRAME) (RETURN (COND (MULTIPLE.HARDCOPY.LIST (SETQ MULTIPLE.HARDCOPY.LIST (CONS (OR (AND INITIAL.DEFAULTPG (ADD1 INITIAL.DEFAULTPG )) 1) MULTIPLE.HARDCOPY.LIST)) (COND (GLOSSARY.FILE (MH.MAKE.GLOSSARY GLOSSARY.FILE) (PRINTOUT T (CONCAT "Glossary file in: " (FULLNAME GLOSSARY.FILE) ) T))) MULTIPLE.HARDCOPY.LIST]) (MH.SET.STARTINGPAGE# [LAMBDA (PG# PAGE.FRAMES) (* edited%: "22-Aug-86 12:15") (* Sets the starting page of a  PAGE.FRAME.) [COND ((LISTP PAGE.FRAMES) (SETQ PAGE.FRAMES (CAR PAGE.FRAMES] (LET ((LOCAL.INFO (fetch REGIONLOCALINFO of PAGE.FRAMES))) (COND (LOCAL.INFO (LISTPUT (fetch REGIONLOCALINFO of PAGE.FRAMES) 'STARTINGPAGE# PG#)) (T (replace REGIONLOCALINFO of PAGE.FRAMES with (LIST 'STARTINGPAGE# PG#]) (MH.GET.PAGE# [LAMBDA (STR) (* edited%: "22-Aug-86 12:13") (* This is meant to extract a number from a string such as "2pgs done." which is  what TEdit prints out when it's finished hardcopying something.  This is unfortunately the way this program relies on to extract how many pages a  file was hardcopied.) (LET ((CH (GNC STR))) (COND ((NUMBERP (MKATOM CH)) (CONCAT CH (MH.GET.PAGE# STR))) (T ""]) (TOC [LAMBDA (FILE) (* ; "Edited 1-Feb-2022 16:47 by rmk") (* edited%: "22-Aug-86 11:48") (* (* N.H.Briggs " 8-Apr-86 11:23")) (LET (TOCSTREAM TOCINFO TOCOUTSTREAM STARTPAGE) (if (LISTP FILE) then (SETQ TOCINFO FILE) else [SETQ TOCINFO (READ (SETQ TOCSTREAM (OPENSTREAM FILE 'INPUT] (CLOSEF TOCSTREAM)) (SETQ TOCOUTSTREAM (OPENTEXTSTREAM NIL)) (SETQ STARTPAGE (CAR TOCINFO)) [for TOCENTRY in (CDR TOCINFO) do (TEDIT.INSERT TOCOUTSTREAM (FILENAMEFIELD (CAR TOCENTRY) 'NAME)) (TEDIT.INSERT TOCOUTSTREAM (CHARACTER (CHARCODE TAB))) (TEDIT.INSERT TOCOUTSTREAM (MKSTRING STARTPAGE)) (TEDIT.INSERT TOCOUTSTREAM (CHARACTER (CHARCODE CR))) (SETQ STARTPAGE (ADD1 (CDR TOCENTRY] (TEDIT.PARALOOKS TOCOUTSTREAM '(TABS (NIL (360 . DOTTEDLEFT)) RIGHTMARGIN 456) 1 (GETEOFPTR TOCOUTSTREAM)) TOCOUTSTREAM]) ) (TEDIT.ADD.MENUITEM TEDIT.DEFAULT.MENU '(MULTIPLE% HARDCOPY 'MULTIPLE.HARDCOPY "HARDCOPY A LIST OF FILES.")) (DECLARE%: DONTCOPY (FILEMAP (NIL (925 10481 (MH.GET.INPUT.FILE 935 . 1531) (MH.MAKE.GLOSSARY 1533 . 2062) ( MULTIPLE.HARDCOPY 2064 . 7788) (MH.SET.STARTINGPAGE# 7790 . 8485) (MH.GET.PAGE# 8487 . 9049) (TOC 9051 . 10479))))) STOP