(FILECREATED "27-Nov-85 14:43:00" {QV}<NOTECARDS>1.3K>FGHPATCH006.;3        

      previous date: "25-Nov-85 19:58:34" {QV}<NOTECARDS>1.3K>FGHPATCH006.;2)


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

(PRETTYCOMPRINT FGHPATCH006COMS)

(RPAQQ FGHPATCH006COMS ((* * Redefined from NCTEXTCARD -- makes all text streams on file have file 
			     relative pointers to aid in 1.2 to 1.3 conversion)
			  (FNS NC.GetTextSubstance NC.PutTextSubstance)
			  (* * Redefined from NCDATABASE to fix bugs and support above.)
			  (FNS NC.CreateDatabaseFile NC.GetNoteCard)))
(* * Redefined from NCTEXTCARD -- makes all text streams on file have file relative pointers 
to aid in 1.2 to 1.3 conversion)

(DEFINEQ

(NC.GetTextSubstance
  (LAMBDA (Card Length)                                      (* fgh: "25-Nov-85 19:54")
                                                             (* Get a text stream from the database file)

          (* * fgh 11/13/85 Updated to handle Card objects.)



          (* * fgh 11/20/85 NoteCards now passes down start and end pointer as args.)



          (* * fgh 11/21/85 Now passed Length instead of start and end ptrs.)


    (LET ((TempStream (OPENSTREAM (QUOTE {NODIRCORE})
				    (QUOTE BOTH)
				    (QUOTE NEW)))
	  (Stream (fetch (NoteFile Stream) of (fetch (Card NoteFile) of Card)))
	  TextStream StartPtr)

          (* * Copy text stream to a NODIRCORE file from the current location. Number of bytes copied should be Length minus 
	  the 4 bytes already read for OriginalLocation)


         (COPYBYTES Stream TempStream (SETQ StartPtr (GETFILEPTR Stream))
		      (PLUS StartPtr Length))

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


         (SETQ TextStream (OPENTEXTSTREAM TempStream NIL NIL NIL (NC.MakeTEditPropsList)))
         (STREAMPROP TextStream (QUOTE NoteCardObject)
		       Card)
     TextStream)))

(NC.PutTextSubstance
  (LAMBDA (Card)                                             (* fgh: "25-Nov-85 19:54")
                                                             (* Put text substance from card ID on the database 
							     file)

          (* * rht 9/13/85: Now doesn't try to write piece table at all if substance has zero length.)



          (* * fgh 11/13/85 Updated to handle NoteFile, Card objects.)



          (* * fgh 11/20/85 removed code to handle start and end pointers)


    (LET ((Substance (NC.FetchSubstance Card))
	  (Stream (fetch (NoteFile Stream) of (fetch (Card NoteFile) of Card)))
	  StartPtr)

          (* * Save the location of the start of this text stream.)


         (SETQ StartPtr (GETFILEPTR Stream))

          (* * The write down the text stream)


         (COND
	   ((NOT (ZEROP (fetch (TEXTOBJ TEXTLEN) of (TEXTOBJ Substance))))
	     (TEDIT.PUT.PCTB (TEXTOBJ Substance)
			       Stream)))

          (* * fix up the file absolute pointerts to be file textstream relative pointers.)


         (if (TEDIT.FORMATTEDFILEP Substance)
	     then (SETFILEPTR Stream (IDIFFERENCE (SETQ EOFPtr (GETEOFPTR Stream))
							8))
		    (SETQ StartFormatPtr (\DWIN Stream))
		    (SETFILEPTR Stream (IDIFFERENCE EOFPtr 8))
		    (\DWOUT Stream (DIFFERENCE StartFormatPtr StartPtr)))

          (* * Set stream file ptr to eof.)


         (SETFILEPTR Stream -1))))
)