(FILECREATED " 4-Jul-86 22:35:34" {QV}<NOTECARDS>1.3K>RHTPATCH055.;1 3635   

      changes to:  (VARS RHTPATCH055COMS))


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

(PRETTYCOMPRINT RHTPATCH055COMS)

(RPAQQ RHTPATCH055COMS ((* * Changes to NCLINKS)
			  (FNS NC.CheckForOrphanDelete NC.FileInOrphanBox)))
(* * Changes to NCLINKS)

(DEFINEQ

(NC.CheckForOrphanDelete
  (LAMBDA (SourceCard DestinationCard SourceWindow)          (* rht: " 4-Jul-86 22:22")

          (* Check to make sure we are not deleteing the last reference to a note card from the orphan card.
	  Last references are okay to delete it since they will be put in the orphan card. But deleting last reference from 
	  the orphan card is very, very bad. Warn the user.)



          (* * kirk: 14Nov85: changed EQs to NC.Same*Ps)



          (* * rht 7/4/86: Brought up to date with 1.3k. E.g. took out mention of NC.OrphansID)


    (LET ((FilingLinks (LIST NC.SubBoxLinkLabel NC.FiledCardLinkLabel))
	  (OrphansCard (fetch (NoteFile OrphansCard) of (fetch (Card NoteFile) of SourceCard))
		       ))
         (AND (NC.SameCardP SourceCard OrphansCard)
		(for Link in (COND
				   ((NC.ActiveCardP DestinationCard)
				     (NC.FetchFromLinks DestinationCard))
				   (T (NC.GetLinks DestinationCard)
				      (NC.FetchFromLinks DestinationCard)))
		   when (FMEMB (fetch (Link Label) of Link)
				   FilingLinks)
		   unless (NC.SameCardP (fetch (Link SourceCard) of Link)
					    OrphansCard)
		   never Link)
		(NC.PrintMsg (NC.FetchWindow SourceCard)
			       T "You have just deleted the last filing link to " (NC.RetrieveTitle
				 DestinationCard)
			       (CHARACTER 13)
			       "The Search operation can be used to find it.")))))

(NC.FileInOrphanBox
  (LAMBDA (Link DestinationCard)                             (* rht: " 4-Jul-86 22:32")

          (* * Hook card to orphan if this is the last link.)



          (* * rht 7/4/86: Changed to call NC.FetchSpecialCards so that RegistryCard, etc. won't have to be filed somewhere.)


    (AND (NOT (FMEMB DestinationCard (NC.FetchSpecialCards (fetch (Card NoteFile)
								      of DestinationCard))))
	   (NOT (NC.SameCardP (fetch (Link SourceCard) of Link)
				  DestinationCard))
	   (NULL (NC.FetchNewCardFlg DestinationCard))
	   (NOT (NC.SameCardP (fetch (Link SourceCard) of Link)
				  NC.OrphanID))
	   (COND
	     ((OR (NULL (NC.FetchFromLinks DestinationCard))
		    (for Link in (NC.FetchFromLinks DestinationCard)
		       always (NC.SameCardP (fetch (Link SourceCard) of Link)
						DestinationCard)))
	       (NC.PrintMsg NIL T "You have just removed the last link to " (NC.RetrieveTitle
				DestinationCard)
			      "."
			      (CHARACTER 13)
			      "It is being filed in the Orphan FileBox.")
	       (NC.HookToOrphanCard DestinationCard))
	     ((for Link in (NC.FetchFromLinks DestinationCard)
		 never (FMEMB (fetch (Link Label) of Link)
				  (QUOTE (SubBox FiledCard))))
	       (NC.PrintMsg NIL T "You have just unfiled " (NC.RetrieveTitle DestinationCard)
			      " from its last filebox."
			      (CHARACTER 13)
			      "It is being filed in the Orphan FileBox.")
	       (NC.HookToOrphanCard DestinationCard))))
    Link))
)
(PUTPROPS RHTPATCH055 COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (370 3553 (NC.CheckForOrphanDelete 380 . 1887) (NC.FileInOrphanBox 1889 . 3551)))))
STOP