(FILECREATED "14-Nov-86 14:34:00" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH150.;2 15461  

      changes to:  (VARS RHTPATCH150COMS)

      previous date: "14-Nov-86 14:32:33" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH150.;1)


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

(PRETTYCOMPRINT RHTPATCH150COMS)

(RPAQQ RHTPATCH150COMS ((* * Fixes problem whereby copystructure was smashing card locs in source 
			     notefile.)
			  (* * Changes to NCDATABASE)
			  (FNS NC.PutMainCardData NC.PutTitle NC.PutLinks NC.PutPropList)))
(* * Fixes problem whereby copystructure was smashing card locs in source notefile.)

(* * Changes to NCDATABASE)

(DEFINEQ

(NC.PutMainCardData
  (LAMBDA (Card UpdateUpdateListFlg UseOldDateFlg OverrideStream)
                                                             (* rht: "14-Nov-86 14:28")

          (* * 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.)



          (* * rht 2/17/86: Fixed so calls to NC.WriteCardPartHeader and to NC.WriteRegion take Stream arg.)



          (* * kef 7/16/86: Makes use of the NoteFile device vector PutCardPartFn.)



          (* * kef 8/1/86: Added notification of status change.)



          (* * fgh 8/31/86 Adapted to use NC.DoCardPartFn.)



          (* * pmi 11/4/86 Reinstated Randy's change (1/23/86) which somehow got lost.)



          (* * rht 11/14/86: Now makes sure hung var PutSuccessfulLoc is NIL if we were passed an OverrideStream.)


    (DECLARE (GLOBALVARS NC.ItemIdentifier))
    (LET (PutSuccessfulLoc)
         (WITH.MONITOR (NC.FetchMonitor (fetch (Card NoteFile) of Card))
		       (NC.DoCardPartFn Put Card (QUOTE SUBSTANCE)
					(LET ((Stream (OR (STREAMP OverrideStream)
							    (NC.CoerceToNoteFileStream Card)))
					      StartDataLoc EndLoc CardType StartSubstanceLoc 
					      SubstanceVersion)

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


					     (AND UpdateUpdateListFlg (NC.UpdateUpdateList Card))

          (* * First write out the card part header)


					     (SETQ StartDataLoc (GETFILEPTR Stream))
					     (NC.WriteCardPartHeader Card NC.ItemIdentifier
								       (COND
									 (UseOldDateFlg (
										 NC.FetchItemDate
											  Card))
									 (T (NC.SetItemDate
									      Card
									      (DATE))))
								       Stream)

          (* * write out the type and region)


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

          (* * 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.)


					     (SETQ EndLoc (GETFILEPTR Stream))
					     (SETFILEPTR Stream StartSubstanceLoc)
					     (NC.WritePtr Stream (DIFFERENCE (DIFFERENCE EndLoc 
										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 StartDataLoc)
					     (NC.WritePtr Stream (DIFFERENCE EndLoc StartDataLoc)
							  3)
					     (SETFILEPTR Stream EndLoc)

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


					     (replace (Card Status) of Card with (QUOTE
											 ACTIVE))

          (* * Don't put a reasonable value in the hung variable PutSuccessfulLoc if we were passed OverrideStream.)


					     (SETQ PutSuccessfulLoc
					       (if OverrideStream
						   then NIL
						 else StartDataLoc))
					 Card))))))

(NC.PutTitle
  (LAMBDA (Card UseOldDateFlg OverrideStream)                (* rht: "14-Nov-86 14:30")

          (* * Put the title of card ID onto DatabaseStream)



          (* * 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 CardID 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.)



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



          (* * kef 7/16/86: Makes use of the NoteFile device vector PutCardPartFn.)



          (* * fgh 8/31/86 Adpated to use NC.DoCardPartFn.)



          (* * pmi 11/4/86 Reinstated Randy's change (1/23/86) which somehow got lost.)



          (* * rht 11/14/86: Now makes sure hung var PutSuccessfulLoc is NIL if we were passed an OverrideStream.)

                                                             (* Check to make sure this is an active note card.)
    (DECLARE (GLOBALVARS NC.TitlesIdentifier))
    (AND (NEQ (fetch (Card Status) of Card)
		  (QUOTE ACTIVE))
	   (NC.ReportError "NC.PutTitle" (CONCAT (NC.FetchTitle Card)
						     " is not an active note card.")))
    (LET (PutSuccessfulLoc)
         (WITH.MONITOR (NC.FetchMonitor (fetch (Card NoteFile) of Card))
		       (NC.DoCardPartFn Put Card (QUOTE TITLE)
					(LET ((Stream (OR (STREAMP OverrideStream)
							    (NC.CoerceToNoteFileStream Card)))
					      StartLoc EndLoc)

          (* * First write out the title.)


					     (SETQ StartLoc (GETFILEPTR Stream))
					     (NC.WriteCardPartHeader Card NC.TitlesIdentifier
								       (COND
									 (UseOldDateFlg (
										NC.FetchTitleDate
											  Card))
									 (T (NC.SetTitleDate
									      Card
									      (DATE))))
								       Stream)
					     (NC.WriteTitle Stream (NC.FetchTitle Card))

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


					     (SETQ EndLoc (GETFILEPTR Stream))
					     (SETFILEPTR Stream StartLoc)
					     (NC.WritePtr Stream (DIFFERENCE EndLoc StartLoc)
							  3)
					     (SETFILEPTR Stream EndLoc)

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


					     (NC.SetTitleDirtyFlg Card)

          (* * Now, since we were successful, we'll bind the PutSuccessfulLoc variable, which will be used freely by the 
	  AFTER PutCardPartFns to determine first if the Put succeeded, and if so, where in the stream it was Put.)



          (* * Don't put a reasonable value in the hung variable PutSuccessfulLoc if we were passed OverrideStream.)


					     (SETQ PutSuccessfulLoc
					       (if OverrideStream
						   then NIL
						 else StartLoc))
					 Card))))))

(NC.PutLinks
  (LAMBDA (Card UseOldDateFlg OverrideStream)                (* rht: "14-Nov-86 14:29")

          (* * Put the link data for ID onto the database file.)



          (* * rht 1/30/85: Changed to use index array instead of file.)



          (* * 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 CardID 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.)



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



          (* * kef 7/16/86: Makes use of the NoteFile device vector PutCardPartFn.)



          (* * fgh 8/31/86 Adapated to use NC.DoCardPartFn.)



          (* * pmi 11/4/86 Reinstated Randy's change (1/23/86) which somehow got lost.)



          (* * rht 11/14/86: Now makes sure hung var PutSuccessfulLoc is NIL if we were passed an OverrideStream.)

                                                             (* Check to make sure this is an active note card.)
    (DECLARE (GLOBALVARS NC.LinksIdentifier))
    (AND (NEQ (fetch (Card Status) of Card)
		  (QUOTE ACTIVE))
	   (NC.ReportError "NC.PutLinks" (CONCAT (NC.FetchTitle Card)
						     " is not an active note card.")))
    (LET (PutSuccessfulLoc)
         (WITH.MONITOR (NC.FetchMonitor (fetch (Card NoteFile) of Card))
		       (NC.DoCardPartFn Put Card (QUOTE LINKS)
					(LET ((Stream (OR (STREAMP OverrideStream)
							    (NC.CoerceToNoteFileStream Card)))
					      StartLoc EndLoc)

          (* * Write the links data at the end of the database file.)


					     (SETQ StartLoc (GETFILEPTR Stream))
					     (NC.WriteCardPartHeader Card NC.LinksIdentifier
								       (COND
									 (UseOldDateFlg (
										NC.FetchLinksDate
											  Card))
									 (T (NC.SetLinksDate
									      Card
									      (DATE))))
								       Stream)
					     (NC.WriteListOfLinks Stream (NC.FetchToLinks Card))
					     (NC.WriteListOfLinks Stream (NC.FetchFromLinks
								      Card))
					     (NC.WriteListOfLinks Stream (NC.FetchGlobalLinks
								      Card))

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


					     (SETQ EndLoc (GETFILEPTR Stream))
					     (SETFILEPTR Stream StartLoc)
					     (NC.WritePtr Stream (DIFFERENCE EndLoc StartLoc)
							  3)
					     (SETFILEPTR Stream EndLoc)

          (* * Now update the index to point to the link data just written. Done last in case writing of links doesn't 
	  complete okay.)


					     (NC.SetLinksDirtyFlg Card)

          (* * Now, since we were successful, we'll bind the PutSuccessfulLoc variable, which will be used freely by the 
	  AFTER PutCardPartFns to determine first if the Put succeeded, and if so, where in the stream it was Put.)



          (* * Don't put a reasonable value in the hung variable PutSuccessfulLoc if we were passed OverrideStream.)


					     (SETQ PutSuccessfulLoc
					       (if OverrideStream
						   then NIL
						 else StartLoc))
					 Card))))))

(NC.PutPropList
  (LAMBDA (Card UseOldDateFlg OverrideStream)                (* rht: "14-Nov-86 14:30")

          (* * Put the prop list for ID onto the database file.)



          (* * rht 1/30/85: Changed to use index array instead of file.)



          (* * 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.)



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



          (* * kef 7/16/86: Makes use of the NoteFile device vector PutCardPartFn.)



          (* * fgh 8/31/86 Adapted to use NC.DoCardPartFn.)



          (* * pmi 11/4/86 Reinstated Randy's change (1/23/86) which somehow got lost.)



          (* * rht 11/14/86: Now makes sure hung var PutSuccessfulLoc is NIL if we were passed an OverrideStream.)

                                                             (* Check to make sure this is an active note card.)
    (DECLARE (GLOBALVARS NC.PropsIdentifier))
    (AND (NEQ (fetch (Card Status) of Card)
		  (QUOTE ACTIVE))
	   (NC.ReportError "NC.PutPropList" (CONCAT (NC.FetchTitle Card)
							" is not an active note card.")))
    (LET (PutSuccessfulLoc)
         (WITH.MONITOR (NC.FetchMonitor (fetch (Card NoteFile) of Card))
		       (NC.DoCardPartFn Put Card (QUOTE PROPLIST)
					(LET ((Stream (OR (STREAMP OverrideStream)
							    (NC.CoerceToNoteFileStream Card)))
					      StartLoc EndLoc)

          (* * Write the proplist at the end of the database file.)


					     (SETQ StartLoc (GETFILEPTR Stream))
					     (NC.WriteCardPartHeader Card NC.PropsIdentifier
								       (COND
									 (UseOldDateFlg (
									     NC.FetchPropListDate
											  Card))
									 (T (NC.SetPropListDate
									      Card
									      (DATE))))
								       Stream)
					     (NC.WritePropList Stream (NC.FetchPropList Card))

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


					     (SETQ EndLoc (GETFILEPTR Stream))
					     (SETFILEPTR Stream StartLoc)
					     (NC.WritePtr Stream (DIFFERENCE EndLoc StartLoc)
							  3)
					     (SETFILEPTR Stream EndLoc)

          (* * Now update the index to point to the proplist just written. Done last in case writing of proplist doesn't 
	  complete okay.)


					     (NC.SetPropListDirtyFlg Card)

          (* * Now, since we were successful, we'll bind the PutSuccessfulLoc variable, which will be used freely by the 
	  AFTER PutCardPartFns to determine first if the Put succeeded, and if so, where in the stream it was Put.)



          (* * Don't put a reasonable value in the hung variable PutSuccessfulLoc if we were passed OverrideStream.)


					     (SETQ PutSuccessfulLoc
					       (if OverrideStream
						   then NIL
						 else StartLoc))
					 Card))))))
)
(PUTPROPS RHTPATCH150 COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (669 15379 (NC.PutMainCardData 679 . 5311) (NC.PutTitle 5313 . 8528) (NC.PutLinks 8530
 . 12033) (NC.PutPropList 12035 . 15377)))))
STOP