(FILECREATED "31-Oct-86 12:17:43" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH128.;1 3564   

      changes to:  (VARS RHTPATCH128COMS)
		   (FNS NCP.GetLinks))


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

(PRETTYCOMPRINT RHTPATCH128COMS)

(RPAQQ RHTPATCH128COMS ((* * Fix to NCP.GetLinks bug reported by Tad.)
			  (* * Change to NCPROGINT)
			  (FNS NCP.GetLinks)))
(* * Fix to NCP.GetLinks bug reported by Tad.)

(* * Change to NCPROGINT)

(DEFINEQ

(NCP.GetLinks
  (LAMBDA (Cards DestinationCards Labels NoteFile)           (* rht: "31-Oct-86 12:16")

          (* * Returns a list of all links from Cards to DestinationCards whose link label is one of Labels.
	  Labels can be nil, in which case all such links are returned. Cards and DestinationCards can each be atomic.
	  Each can also be nil. For example, if DestinationCards is nil, then all links pointing from Cards to anywhere with 
	  given labels are returned. Note that if both Cards and DestinationCards are nil, then will return all links whose 
	  label is one of Labels. If all three args are nil, then return all links in the current notefile.)



          (* * rht 11/17/85: Updated to handle new card and notefile objects.)



          (* * rht 8/29/86: Now blocks in loops and checks whether links cached before retrieving.)


    (LET (ValidCards ValidDestinationCards)
         (SETQ Labels (MKLIST Labels))
         (SETQ ValidCards (for Card in (MKLIST Cards) eachtime (BLOCK)
			       unless (COND
					  ((NOT (NC.ValidCardP Card))
					    (NCP.ReportError Card " not an existing card or box.")
					    T))
			       collect Card))
         (SETQ ValidDestinationCards (for Card in (MKLIST DestinationCards) eachtime
										     (BLOCK)
					  unless (COND
						     ((NOT (NC.ValidCardP Card))
						       (NCP.ReportError Card 
								  " not an existing card or box.")
						       T))
					  collect Card))
         (COND
	   (Cards (for Card in ValidCards eachtime (BLOCK)
		     join (LET ((HadLinksCachedFlg (NC.LinksCachedP Card)))
			         (PROG1 (for Link in (NC.RetrieveToLinks Card)
					     when (COND
						      (DestinationCards (FMEMB (fetch
										   (Link 
										  DestinationCard)
										    of Link)
										 
									    ValidDestinationCards))
						      (T T))
					     when (COND
						      (Labels (FMEMB (fetch (Link Label)
									  of Link)
								       Labels))
						      (T T))
					     collect Link)
					  (OR HadLinksCachedFlg (NC.UncacheLinks Card))))))
	   (DestinationCards (for Card in ValidDestinationCards eachtime (BLOCK)
				join (LET ((HadLinksCachedFlg (NC.LinksCachedP Card)))
					    (PROG1 (for Link in (NC.RetrieveFromLinks Card)
							when (COND
								 (Labels (FMEMB
									   (fetch (Link Label)
									      of Link)
									   Labels))
								 (T T))
							collect Link)
						     (OR HadLinksCachedFlg (NC.UncacheLinks
							     Card))))))
	   (T (NCP.MapLinks NoteFile (FUNCTION PROG1)
			    (FUNCTION (LAMBDA (Link)
				(if Labels
				    then (FMEMB (fetch (Link Label) of Link)
						    Labels)
				  else T)))))))))
)
(PUTPROPS RHTPATCH128 COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (476 3482 (NCP.GetLinks 486 . 3480)))))
STOP