(FILECREATED " 9-Sep-87 12:35:31" {QV}<NOTECARDS>1.3KNEXT>PMIPATCH062.;2 5766   

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

      previous date: " 8-Sep-87 17:43:45" {QV}<NOTECARDS>1.3KNEXT>PMIPATCH062.;1)


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

(PRETTYCOMPRINT PMIPATCH062COMS)

(RPAQQ PMIPATCH062COMS ((* * pmi 9/8/87: Fixes several cross-file link/browser bugs reported by Len 
			     Gaska.)
			  (* * Changed in NCCROSSFILELINKS)
			  (FNS NC.GetCrossFileLinkDestCard)
			  (* * Changed in NCDATABASE)
			  (FNS NC.CardFromUID)))
(* * pmi 9/8/87: Fixes several cross-file link/browser bugs reported by Len Gaska.)

(* * Changed in NCCROSSFILELINKS)

(DEFINEQ

(NC.GetCrossFileLinkDestCard
  (LAMBDA (CrossFileLinkCard InterestedWindow Don'tOpenDestNoteFileFlg)
                                                             (* pmi: " 8-Sep-87 17:41")

          (* * 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.)



          (* * rht 12/16/86: Now takes InterestedWindow argument.)



          (* * rht 3/25/87: Now calls NC.CoerceToInterestedWindow.)



          (* * rht 3/27/87: Now calls NC.OpenCrossFileLinkDestNoteFile.)



          (* * rht 5/27/87: New arg Don'tOpenDestNoteFileFlg. If non-nil, then destination notefile has to be already open.)



          (* * rht 6/4/87: Now passes CrossFileLinkCard to NC.OpenCrossFileLinkDestNoteFile.)



          (* * rht 6/8/87: Now computes WasOpenPromptWindowFlg)



          (* * pmi 8/7/87: Now gets a filename if it has to loop and ask for another notefile to try.)



          (* * pmi 9/8/87: Now sets Don'tOpenDestNoteFileFlg to the results of NC.OpenCrossFileLinkDestNoteFile)


    (LET ((Title (NC.FetchTitle CrossFileLinkCard))
	  (SourceNoteFile (fetch (Card NoteFile) of CrossFileLinkCard))
	  Substance DestNoteFileUID DestFileHint DestCardUID DestNoteFile DestFileName Card 
	  WasOpenPromptWindowFlg)
         (OR InterestedWindow (SETQ InterestedWindow (NC.CoerceToInterestedWindow 
										   SourceNoteFile)))
         (SETQ WasOpenPromptWindowFlg (NC.PromptWindowOpenP InterestedWindow))
         (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 DestNoteFile (NC.NoteFileFromNoteFileUID DestNoteFileUID))
         (SETQ DestFileName (OR (AND (type? NoteFile DestNoteFile)
					   (fetch (NoteFile FullFileName) of DestNoteFile))
				    DestFileHint))
         (for while (if Don'tOpenDestNoteFileFlg
			    then (NCP.OpenNoteFileP DestNoteFile)
			  else (SETQ Don'tOpenDestNoteFileFlg
				   (NULL (SETQ DestNoteFile (NC.OpenCrossFileLinkDestNoteFile
					       DestNoteFile DestFileName InterestedWindow 
					       CrossFileLinkCard))))
				 (SETQ DestFileName (OR DestFileName (AND (type? NoteFile 
										     DestNoteFile)
										(fetch
										  (NoteFile 
										     FullFileName)
										   of DestNoteFile))
							    )))
	    bind NewFileName
	    do (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 (if Don'tOpenDestNoteFileFlg
			      then (RETURN NIL)
			    else (NC.PrintMsg InterestedWindow T 
						  "Couldn't find destination card in "
						  DestFileName "." (CHARACTER 13))
				   (if (NOT (NC.AskYesOrNo 
						     "Want to try opening a different notefile? "
								 " -- " "Yes" NIL InterestedWindow 
								 WasOpenPromptWindowFlg))
				       then (RETURN NIL)
				     else (SETQ DestNoteFile (SETQ DestFileName NIL)))))))))
)
(* * Changed in NCDATABASE)

(DEFINEQ

(NC.CardFromUID
  (LAMBDA (UID NoteFile)                                   (* pmi: " 8-Sep-87 17:30")

          (* * Recover the card with given UID by looking it up in the notefile's hash table.)



          (* * pmi 9/8/87: Now returns NIL if either UID or NoteFile are NIL.)


    (AND UID NoteFile (GETHASH UID (fetch (NoteFile HashArray) of NoteFile)))))
)
(PUTPROPS PMIPATCH062 COPYRIGHT ("Xerox Corporation" 1987))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (745 5240 (NC.GetCrossFileLinkDestCard 755 . 5238)) (5275 5684 (NC.CardFromUID 5285 . 
5682)))))
STOP