(FILECREATED "11-Dec-86 12:40:00" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH173.;1 4646   

      changes to:  (VARS RHTPATCH173COMS)
		   (FNS NC.GetCrossFileLinkDestCard))


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

(PRETTYCOMPRINT RHTPATCH173COMS)

(RPAQQ RHTPATCH173COMS ((* * Fixes bug #330: deleting dest card of crossfile link causes break when 
			     link is followed.)
			  (* * Change to NCCROSSFILELINKS)
			  (FNS NC.GetCrossFileLinkDestCard)))
(* * Fixes bug #330: deleting dest card of crossfile link causes break when link is followed.)

(* * Change to NCCROSSFILELINKS)

(DEFINEQ

(NC.GetCrossFileLinkDestCard
  (LAMBDA (CrossFileLinkCard)                                (* rht: "11-Dec-86 12:37")

          (* * Find the notefile corresponding to this crossfilelink and try to open it if not already open.
	  Then look for the card in there having the given UID. Return NIL if failed for any reason.)



          (* * rht 11/10/86: Make sure CrossFileLinkCard is cached before fetching substance.)



          (* * rht 11/19/86: Now rips off version number from destination notefile hint.)



          (* * rht 12/11/86: Now checks that destination card is not deleted.)


    (LET ((Title (NC.FetchTitle CrossFileLinkCard))
	  (SourceNoteFile (fetch (Card NoteFile) of CrossFileLinkCard))
	  Substance DestNoteFileUID DestFileHint DestCardUID DestNoteFile DestFileName 
	  InterestedWindow WasOpenFlg)
         (if (NOT (NC.ActiveCardP CrossFileLinkCard))
	     then (NC.GetNoteCard CrossFileLinkCard))
         (SETQ Substance (NC.FetchSubstance CrossFileLinkCard))
         (SETQ DestCardUID (fetch (CrossFileLinkSubstance CrossFileLinkDestCardUID) of 
											Substance))
         (SETQ DestNoteFileUID (fetch (CrossFileLinkSubstance CrossFileLinkDestNoteFileUID)
				    of Substance))
         (SETQ DestFileHint (fetch (CrossFileLinkSubstance CrossFileLinkDestFileHint)
				 of Substance))
         (SETQ InterestedWindow (WFROMMENU (fetch (NoteFile Menu) of SourceNoteFile)))
         (SETQ DestNoteFile (NC.NoteFileFromNoteFileUID DestNoteFileUID))
         (SETQ DestFileName (OR (AND (type? NoteFile DestNoteFile)
					   (fetch (NoteFile FullFileName) of DestNoteFile))
				    DestFileHint))
         (if (OR (SETQ WasOpenFlg (NCP.OpenNoteFileP DestNoteFile))
		     (NC.AskYesOrNo (CONCAT "Trying to follow cross-file link to " Title "."
						(CHARACTER 13)
						"Okay to try opening " DestFileName "? ")
				      NIL "Yes" T InterestedWindow NIL NIL))
	     then (for while DestFileName bind Card NewFileName
		       do (if (OR (NCP.OpenNoteFileP DestNoteFile)
					(NCP.OpenNoteFileP (SETQ DestNoteFile
							       (NC.OpenNoteFile (OR DestNoteFile 
										     DestFileName)
										  NIL NIL NIL NIL NIL 
										  NIL NIL NIL 
										 InterestedWindow))))
				then (if (NC.ValidCardP (SETQ Card (NC.CardFromUID 
										      DestCardUID 
										     DestNoteFile)))
					   then (if (NOT (EQUAL (SETQ NewFileName
									  (fetch (NoteFile 
										     FullFileName)
									     of DestNoteFile))
									(FULLNAME
									  (fetch (
CrossFileLinkSubstance CrossFileLinkDestFileHint) of Substance))))
						      then (replace (CrossFileLinkSubstance
									  CrossFileLinkDestFileHint)
								of Substance
								with (PACKFILENAME (QUOTE
											 VERSION)
										       NIL
										       (QUOTE
											 BODY)
										       NewFileName))
							     (NC.MarkCardDirty CrossFileLinkCard))
						  (RETURN Card)
					 else (NC.PrintMsg InterestedWindow T 
							     "Couldn't find destination card in "
							       DestFileName "." (CHARACTER 13))
						(OR WasOpenFlg (NC.AbortSession DestNoteFile 
										 InterestedWindow T)))
			      else (NC.PrintMsg InterestedWindow T "Couldn't open " DestFileName 
						    "."
						    (CHARACTER 13)))
			    (SETQ DestFileName (SETQ DestNoteFile NIL))
			    (AND (NC.AskYesOrNo "Want to try opening a different notefile? " NIL 
						    "Yes"
						    NIL InterestedWindow)
				   (SETQ DestFileName (NC.AskUser "File name to try opening: " 
								      NIL NIL T InterestedWindow))))))
    ))
)
(PUTPROPS RHTPATCH173 COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (625 4564 (NC.GetCrossFileLinkDestCard 635 . 4562)))))
STOP