(FILECREATED "14-Feb-86 15:20:48" {QV}<NOTECARDS>1.3K>RHTPATCH028.;3 6469   

      changes to:  (VARS RHTPATCH028COMS)
		   (FNS NC.AddFromLink NC.AddToLink NC.DelToLink NC.UncacheLinks NC.DelFromLink)

      previous date: "14-Feb-86 15:09:41" {QV}<NOTECARDS>1.3K>RHTPATCH028.;1)


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

(PRETTYCOMPRINT RHTPATCH028COMS)

(RPAQQ RHTPATCH028COMS ((* * These hacks are for fixing the link uncaching problem.)
			  (* * Following is a new function for NCLINKS)
			  (FNS NC.UncacheLinks)
			  (* * These functions in NCLINKS changed to call above.)
			  (FNS NC.DelFromLink NC.DelToLink NC.AddFromLink NC.AddToLink)))
(* * These hacks are for fixing the link uncaching problem.)

(* * Following is a new function for NCLINKS)

(DEFINEQ

(NC.UncacheLinks
  (LAMBDA (Card)                                             (* rht: "14-Feb-86 15:06")

          (* * Throw away the links cache for this card.)


    (replace (Card Links) of Card with NIL)))
)
(* * These functions in NCLINKS changed to call above.)

(DEFINEQ

(NC.DelFromLink
  (LAMBDA (Link NoOrphanHookFlg)                             (* rht: "14-Feb-86 15:08")

          (* * Delete a FromLink from its destination card Hook card to orphan if this is the last link.)



          (* * rht 11/15/84: Changed decision as to when to orphanize a card. Now must have deleted its last link 
	  (not just last subbox or filedcard link). Also checks that link doesn't point from card to itself.)



          (* * rht 12/1/84: Now doesn't do any work unless ID is valid, i.e. not DELETED or FREE.)



          (* * kirk: 13Nov85: deleted of use of DatabaseStream and changed to call CachedDelFromLink.)



          (* * kirk 29Jan86 Changed to a direct recursive call eliminating CachedDelFromLink. Added NC.FileInOrphanBox.)



          (* * rht 2/14/86: Now calls NC.UncacheLinks instead of two calls to NC.SetToLinks and NC.SetFromLinks.)


    (LET ((DestinationCard (fetch (Link DestinationCard) of Link)))
         (COND
	   ((NC.ValidCardP DestinationCard)
	     (COND
	       ((NC.ActiveCardP DestinationCard)
		 (NC.CachedDelFromLink Link DestinationCard)
		 (OR NoOrphanHookFlg (NC.FileInOrphanBox Link DestinationCard)))
	       (T (WITH.MONITOR (NC.FetchMonitor (fetch (Card NoteFile) of DestinationCard))
				(NC.GetLinks DestinationCard)
				(NC.CachedDelFromLink Link DestinationCard)
				(NC.PutLinks DestinationCard)
				(OR NoOrphanHookFlg (NC.FileInOrphanBox Link DestinationCard))
				(NC.UncacheLinks DestinationCard))
		  Link)))))))

(NC.DelToLink
  (LAMBDA (Link)                                             (* rht: "14-Feb-86 15:12")

          (* * Delete ToLink spoecified by Link from cards on DatabasseStream)



          (* * rht 12/1/84: Now doesn't do any work unless SourceCard is valid, i.e. not DELETED or FREE.)



          (* * kirk: 13Nov85: changed to use NoteFile from card from link instead of DatabaseStream)



          (* * rht 2/14/86: Now calls NC.UncacheLinks instead of two calls to NC.SetToLinks and NC.SetFromLinks.)


    (PROG ((SourceCard (fetch (Link SourceCard) of Link)))
	    (COND
	      ((NOT (NC.ValidCardP SourceCard)))
	      ((NC.ActiveCardP SourceCard)
		(NC.SetToLinks SourceCard (DREMOVE (for OldLink in (NC.FetchToLinks 
										       SourceCard)
							  thereis (AND (NC.SameLinkP Link 
											  OldLink)
									   OldLink))
						       (NC.FetchToLinks SourceCard)))
		(NC.SetLinksDirtyFlg SourceCard T))
	      (T (WITH.MONITOR (NC.FetchMonitor (fetch (Card NoteFile) of SourceCard)
						  "NC.AddFromLink")
			       (NC.GetLinks SourceCard)
			       (NC.SetToLinks SourceCard (DREMOVE (for OldLink
									 in (NC.FetchToLinks
										SourceCard)
									 thereis
									  (AND (NC.SameLinkP
										   Link OldLink)
										 OldLink))
								      (NC.FetchToLinks SourceCard)))
			       (NC.SetLinksDirtyFlg SourceCard T)
			       (NC.PutLinks SourceCard))
		 (NC.UncacheLinks SourceCard)))
	    (RETURN Link))))

(NC.AddFromLink
  (LAMBDA (Link)                                             (* rht: "14-Feb-86 15:17")

          (* * Add Link to the FromLinks of the appropraite card on DatbaseStream)



          (* * kirk: 14Nov85: deleted use of of DatabaseStream)



          (* * rht 2/14/86: Now calls NC.UncacheLinks instead of two calls to NC.SetToLinks and NC.SetFromLinks.)


    (LET ((Card (fetch (Link DestinationCard) of Link)))
         (COND
	   ((NC.ActiveCardP Card)
	     (NC.SetFromLinks Card (CONS Link (NC.FetchFromLinks Card)))
	     (NC.SetLinksDirtyFlg Card T))
	   (T (WITH.MONITOR (NC.FetchMonitor (fetch (Card NoteFile) of Card))
			    (NC.GetLinks Card)
			    (NC.SetFromLinks Card (CONS Link (NC.FetchFromLinks Card)))
			    (NC.SetLinksDirtyFlg Card T)
			    (NC.PutLinks Card)
			    (NC.UncacheLinks Card))))
     Link)))

(NC.AddToLink
  (LAMBDA (Link LinkToInsertAfter)                           (* rht: "14-Feb-86 15:20")

          (* * Add Link to the ToLinks of the source card)



          (* * rht 3/26/85: Added LinkToInsertAfter arg which is either NIL, ATEND, or a link after which to insert new link.
	  If NIL, then insert at front of list. If ATEND then insert at end.)



          (* * kirk: 13Nov85: deleted second parameter (DatabaseSTream) and changed to call NC.CachedAddToLink.)



          (* * rht 2/14/86: Now calls NC.UncacheLinks instead of two calls to NC.SetToLinks and NC.SetFromLinks.)


    (LET ((SourceCard (fetch (Link SourceCard) of Link)))
         (COND
	   ((NC.ActiveCardP SourceCard)
	     (NC.CachedAddToLink Link SourceCard LinkToInsertAfter))
	   (T (WITH.MONITOR (NC.FetchMonitor (fetch (Card NoteFile) of SourceCard))
			    (NC.GetLinks SourceCard)
			    (NC.CachedAddToLink Link SourceCard LinkToInsertAfter)
			    (NC.PutLinks SourceCard)
			    (NC.UncacheLinks SourceCard)))))
    Link))
)
(PUTPROPS RHTPATCH028 COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (807 1054 (NC.UncacheLinks 817 . 1052)) (1117 6387 (NC.DelFromLink 1127 . 2729) (
NC.DelToLink 2731 . 4349) (NC.AddFromLink 4351 . 5289) (NC.AddToLink 5291 . 6385)))))
STOP