(FILECREATED "18-Dec-86 18:27:09" {QV}<NOTECARDS>1.3K>NEXT>RGPATCH007.;2 2584   

      changes to:  (FNS NC.MakeChildLink NC.EnsureNoCycles)
		   (VARS RGPATCH007COMS)

      previous date: "18-Dec-86 18:26:12" {QV}<NOTECARDS>1.3K>NEXT>RGPATCH007.;1)


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

(PRETTYCOMPRINT RGPATCH007COMS)

(RPAQQ RGPATCH007COMS ((* * new fn for NCLINKS)
			 (FNS NC.EnsureNoCycles)
			 (P (ADDTOFILE (QUOTE NC.EnsureNoCycles)
				       (QUOTE FNS)
				       (QUOTE NCLINKS)
				       (QUOTE NC.MakeChildLink)))
			 (* * changes to NCLINKS)
			 (FNS NC.MakeChildLink)))
(* * new fn for NCLINKS)

(DEFINEQ

(NC.EnsureNoCycles
  [LAMBDA (Parent Child LinkPredicate InterestedWindow)      (* Randy.Gobbel "18-Dec-86 18:14")

          (* * Return T if no cycles via specified link predicate, else NIL.)


    (COND
      ([for Link in (NC.FetchToLinks Parent) thereis (AND (APPLY* LinkPredicate Link)
								    (NC.SameCardP
								      Child
								      (fetch (Link DestinationCard)
									 of Link]
	(NC.PrintMsg InterestedWindow NIL (NC.RetrieveTitle Child)
		       " is already a child of "
		       (NC.RetrieveTitle Parent)
		       (CHARACTER 13))
	NIL)
      ((AND (NEQ Parent Child)
	      (NC.NotDaughterP Child Parent LinkPredicate))
	T)
      (T (NC.PrintMsg InterestedWindow T (NC.RetrieveTitle Child)
			" is an ancestor of "
			(NC.RetrieveTitle Parent)
			(CHARACTER 13))
	 NIL])
)
(ADDTOFILE (QUOTE NC.EnsureNoCycles)
	   (QUOTE FNS)
	   (QUOTE NCLINKS)
	   (QUOTE NC.MakeChildLink))
(* * changes to NCLINKS)

(DEFINEQ

(NC.MakeChildLink
  [LAMBDA (Child Parent Window)                              (* Randy.Gobbel "18-Dec-86 18:26")

          (* * Tries to add Child as a child of Parent using either FiledCard or SubBox link as appropriate.
	  Won't allow if would cause a cycle. Returns new link if successful, else NIL.)



          (* * kirk 14Nov85: deleted use of PSA.Database)



          (* * rg 12/18/86: Cycle-checking code moved to NC.EnsureNoCycles)


    (DECLARE (GLOBALVARS NC.SubBoxLinkLabel NC.FiledCardLinkLabel))
    (AND (NC.EnsureNoCycles Parent Child (FUNCTION NC.ChildLinkP)
				Window)
	   (NC.MakeFilingLink Parent Child (if (NC.FileBoxP Child T)
						 then NC.SubBoxLinkLabel
					       else NC.FiledCardLinkLabel])
)
(PUTPROPS RGPATCH007 COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (661 1565 (NC.EnsureNoCycles 671 . 1563)) (1700 2503 (NC.MakeChildLink 1710 . 2501)))))
STOP