;;; -*- Mode:LISP; Package:USER; Readtable:CL; Base:10 -*-

(defvar *docinst-file* "it:keith.release-3;docinst.text")

(defvar *docinst*
	'((3odm "3.0 On-Line Document Manager" 3142-0000 C 50)
	  (3sited "3.0 Site Data Editor" 3239-0000 B 50)
	  (3fonted "3.0 Font Editor" 3141-0000 C 50)
	  (3tape "3.0 Tape Software" 3138-0000 C 50)
	  (3printer "3.0 Printer Software" 2202-0000 C 50)
	  (3bugs "3.0 Bugs and Limitations" 3075-0000 C 50)
	  (3notes "Release 3.0 Notes" 2921-0000 C 50)
	  (3ops "3.0 Lambda Operations Manual" 3149-0000 C 50)
	  (3obj-user "3.0 ObjectLISP User Manual" 3057-0000 C 50 )
	  (3obj-notes "3.0 ObjectLISP Release Notes" 3240-0000 C 50)
	  (3patch "3.1 Patch Update" 3329-0000 B 50)
	  (3tcp-user "3.0 TCP/IP User Manual" 3167-0000 C 10)
	  (3tcp-notes "3.0 TCP/IP Release Notes and Installation" 3168-0000 C 10)
;	  (3vista-lib-instl "3.0 Vista Library Installation" 3232-0000 B)
	  (3iris-notes "3.0 Iris Notes" 3233-0000 B 10)
	  (3vista-instl "3.0 Vista Installation" 3235-0000 B 10)
	  (3vista-user "3.0 Vista VISOBS User Manual" 3272-0000 B 10)
	  (3vista-notes "3.0 Vista Release Notes"  3273-0000 B 10)
	  (3vista-lib-user "3.0 Vista Library User Manual" 3276-0000 B 10)
	  (3lplus "Laser1-Plus Release Notes" 3300-0000 B 10)
	  ))

(defvar *template*
	"
              **********************************************
                Deliver to:

                           Gigamos Systems Inc.
                              650 Suffolk St.
                             Lowell, MA 01844
                            ATTN: Documentation
              **********************************************
                 This is a documentation MASTER COPY.  If
                  found, please return to above address,
              **********************************************



TITLE:             %TITLE                                                   

PART NUMBER:       %PARTNO        REV %REV     

PAGES (ORIGINAL):  %PAGES

QUANTITY TO PRINT: %QTY           INITIALS:  ______


                       *** COPYING INSTRUCTIONS ***

        * Front and back covers: medium stock, cream color
          - Front cover has Gigamos logo, title text
          - Back cover is plain heavy sheet (no text)

        * Copy (high quality) on 3-hole punched paper

        * All inside sheets on white paper; only title
          page gets copied onto medium stock / color

        * PHOTOCOPYING INSTRUCTIONS:
          - First stapled set - title, inside cover(s) -
            must be copied 1-sided (marked \"blank back\")
          - Remaining pages: must be copied 2-sided
            from the 1-sided original
          - Page 'i' must be a TOP page (punch on left)
          - Page '1' must be a TOP page (punch on left)
          - All ODD-numbered pages must be TOP page, with
            next EVEN-numbered page on BACK



                                                        8/14/87
")

(defun docinsert(str key thing)
  (let((indx (string-search key str)))
    (when indx
      (setf (subseq str indx)
	    (format nil
		    (typecase thing
		      ((or string symbol) "~va")
		      (t "~vs"))
		    (string-length key)
		    thing)))))

(defun docinst(title partno rev qty &optional pages)
  (let((templ (make-string (length *template*))))
    (setf (subseq templ 0) *template*)
    (docinsert templ "%title" title)
    (docinsert templ "%partno" partno)
    (docinsert templ "%rev" rev)
    (docinsert templ "%qty" qty)
    (docinsert templ "%pages" (or pages "______"))
    templ))

(defun save-docinst(&optional docnames (pathname *docinst-file*))
  (unless docnames (setq docnames (mapcar #'car *docinst*)))
  (with-open-file (out pathname :direction :output)
    (do*((docs docnames (cdr docs))
	 (doc (car docs) (car docs))
	 (args (cdr(assoc doc *docinst*))  (cdr(assoc doc *docinst*)))
	 (str))
	((null docs))
      (setq str  (apply #'docinst args))
      (format out "~&~a~&~@[~|~]"
	      str (cdr docs)))))
	  
