(FILECREATED " 2-May-85 15:33:37" {PHYLUM}<NOTECARDS>RELEASE1.2>FGHPATCH009.;3 3575   

      changes to:  (FNS NC.GetTextSubstance)
		   (VARS FGHPATCH009COMS)

      previous date: " 2-May-85 14:27:34" {PHYLUM}<NOTECARDS>RELEASE1.2>FGHPATCH009.;1)


(* Copyright (c) 1985 by Xerox Corporation. All rights reserved.)

(PRETTYCOMPRINT FGHPATCH009COMS)

(RPAQQ FGHPATCH009COMS ((FNS NC.PutTextSubstance NC.GetTextSubstance)))
(DEFINEQ

(NC.PutTextSubstance
  (LAMBDA (ID DatabaseStream)                                (* fgh: " 2-May-85 14:25")
                                                             (* Put text substance from card ID on the database 
							     file)
    (PROG ((Substance (NC.FetchSubstance ID))
	   EndPtr EndPtrLoc StartPtr TempStream)
          (SETQ TempStream (GETSTREAM (fetch (TEXTOBJ TXTFILE) of (TEXTOBJ Substance))))
          (SETQ StartPtr (IPLUS (GETFILEPTR DatabaseStream)
				6))
          (NC.PutPtr DatabaseStream StartPtr)
          (SETQ EndPtrLoc (GETFILEPTR DatabaseStream))
          (NC.PutPtr DatabaseStream 0)
          (AND (ZEROP (fetch (TEXTOBJ TEXTLEN) of (TEXTOBJ Substance)))
	       (TEDIT.INSERT Substance "   " 1))
          (TEDIT.PUT.PCTB (TEXTOBJ Substance)
			  DatabaseStream)
          (SETQ EndPtr (GETFILEPTR DatabaseStream))
          (SETFILEPTR DatabaseStream EndPtrLoc)
          (NC.PutPtr DatabaseStream EndPtr)                  (* Fix up PCTB of Substance in case want to go on 
							     editing.)
          (TEDIT.MAPPIECES (TEXTOBJ Substance)
			   (FUNCTION (LAMBDA (CH# PC PC# OBL)
			       (COND
				 ((EQ (FULLNAME (fetch (PIECE PFILE) of PC))
				      (FULLNAME DatabaseStream))
				   (replace (PIECE PFILE) of PC with TempStream)
				   (replace (PIECE PFPOS) of PC with (IDIFFERENCE
								       (fetch (PIECE PFPOS)
									  of PC)
								       StartPtr))))))))))

(NC.GetTextSubstance
  (LAMBDA (DatabaseStream ID Region)                         (* fgh: " 2-May-85 15:33")
                                                             (* Get a text stream from the database file)
    (PROG ((TempStream (OPENSTREAM (QUOTE {NODIRCORE})
				   (QUOTE BOTH)
				   (QUOTE NEW)))
	   StartPtr EndPtr StartFormatPtr TempFileEof)
          (SETQ StartPtr (NC.GetPtr DatabaseStream))
          (SETQ EndPtr (NC.GetPtr DatabaseStream))

          (* * Copy text stream to a NODIRCORE file)


          (COPYBYTES DatabaseStream TempStream StartPtr EndPtr)

          (* * fix up file absolute pinter to the beginning of the formatting nformation)


          (COND
	    ((IGREATERP (SETQ TempFileEof (GETEOFPTR TempStream))
			2)
	      (SETFILEPTR TempStream (IDIFFERENCE TempFileEof 2))
	      (COND
		((FMEMB (\WIN TempStream)
			(QUOTE (31415 31416 31417)))
		  (SETFILEPTR TempStream (IDIFFERENCE TempFileEof 8))
		  (SETQ StartFormatPtr (\DWIN TempStream))
		  (SETFILEPTR TempStream (IDIFFERENCE TempFileEof 8))
		  (\DWOUT TempStream (IDIFFERENCE StartFormatPtr StartPtr))))))

          (* * return an open textstream on the temp file)


          (RETURN (OPENTEXTSTREAM TempStream NIL NIL NIL (LIST (QUOTE FONT)
							       NC.DefaultFont))))))
)
(PUTPROPS FGHPATCH009 COPYRIGHT ("Xerox Corporation" 1985))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (435 3493 (NC.PutTextSubstance 445 . 2065) (NC.GetTextSubstance 2067 . 3491)))))
STOP