(FILECREATED "14-Feb-86 18:48:09" {QV}<NOTECARDS>1.3K>RHTPATCH029.;1 4146   

      changes to:  (VARS RHTPATCH029COMS)
		   (FNS NC.PutMainCardData))


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

(PRETTYCOMPRINT RHTPATCH029COMS)

(RPAQQ RHTPATCH029COMS ((* * A simple fix to a fn in NCDATABASE)
			  (FNS NC.PutMainCardData)))
(* * A simple fix to a fn in NCDATABASE)

(DEFINEQ

(NC.PutMainCardData
  (LAMBDA (Card UpdateUpdateListFlg UseOldDateFlg OverrideStream)
                                                             (* rht: "14-Feb-86 18:44")

          (* * Write note card specified by ID to the database specified by Database stream)



          (* * rht 7/9/85: Now puts out date after identifier. If UseOldDateFlg is non-nil, then use old date, otherwise use 
	  current date.)



          (* * rht 11/10/85: Updated to handle NoteFile and Card scheme.)



          (* * fgh 11/20/85 Added call to NC.WriteCardPartHeader and the mechanism to write the start and end pointers of the
	  substance before calling the card type's putfn.)



          (* * kirk 29Nov85 Renamed from NC.PutNoteCard)



          (* * rht 1/23/86: Now takes optional OverrideStream arg. This, if given, overrides stream of card's notefile.)



          (* * fgh 2/5/86 Added call to NC.ApplyFn)



          (* * fgh 2/6/86 Added support for version numbers on the substance put fn.)



          (* * kirk 14Feb86 Merged above two changes)



          (* * rht 2/14/86: Fixed so call to NC.WriteCardType takes Stream as arg.)


    (WITH.MONITOR (NC.FetchMonitor (fetch (Card NoteFile) of Card))
		  (LET ((Stream (OR (STREAMP OverrideStream)
				      (NC.CoerceToNoteFileStream Card)))
			DataLoc CardType StartSubstanceLoc SubstanceVersion)

          (* * Record update date on update list if necessary.)


		       (AND UpdateUpdateListFlg (NC.UpdateUpdateList Card))

          (* * First write out the card part header)


		       (SETFILEPTR Stream (SETQ DataLoc (GETEOFPTR Stream)))
		       (NC.WriteCardPartHeader Card NC.ItemIdentifier (COND
						   (UseOldDateFlg (NC.FetchItemDate Card))
						   (T (NC.SetItemDate Card (DATE)))))

          (* * write out the type and region)


		       (NC.WriteCardType Stream (SETQ CardType (NC.RetrieveType Card)))
		       (NC.WriteRegion Card)

          (* * Write out the dummy length pointer for and version byte the actual substance)


		       (SETQ StartSubstanceLoc (GETFILEPTR Stream))
		       (NC.WritePtr Stream 0 4)

          (* * Write out the substance of the card.)


		       (SETQ SubstanceVersion (NC.ApplyFn PutFn Card Stream))

          (* * Update the length pointer at beginning of substance Subtract four so that length is the length of the actual 
	  substance and doesn't include the length pointer and version byte maintained here. Also updated the version number 
	  returned by the put fn.)


		       (SETFILEPTR Stream StartSubstanceLoc)
		       (NC.WritePtr Stream (DIFFERENCE (DIFFERENCE (GETEOFPTR Stream)
								       StartSubstanceLoc)
							 4)
				    3)
		       (SETQ SubstanceVersion (OR SubstanceVersion 0))
		       (NC.WritePtr Stream SubstanceVersion 1)

          (* * Update the length field at the beginning of the card info)


		       (SETFILEPTR Stream DataLoc)
		       (NC.WritePtr Stream (DIFFERENCE (GETEOFPTR Stream)
							 DataLoc)
				    3)
		       (SETFILEPTR Stream -1)

          (* * Now update the Index to reflect the new data just written. Done last in case the substance putting bombed for 
	  some reason.)



          (* * Only update if no OverrideStream.)


		       (if (NOT (STREAMP OverrideStream))
			   then (replace (Card Status) of Card with (QUOTE ACTIVE)))
		       (NC.SetMainLoc Card DataLoc)
		   Card))))
)
(PUTPROPS RHTPATCH029 COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (408 4064 (NC.PutMainCardData 418 . 4062)))))
STOP