(FILECREATED " 7-Aug-87 10:39:24" {QV}<NOTECARDS>1.3KNEXT>PMIPATCH054.;1 7807   

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


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

(PRETTYCOMPRINT PMIPATCH054COMS)

(RPAQQ PMIPATCH054COMS ((* * pmi 8/7/87: Fixes bug %#630: prompt for filename doesn't append 
			     ".notefile.")
			  (* * Changed in NCCROSSFILELINKS)
			  (FNS NC.GetCrossFileLinkDestCard NC.OpenCrossFileLinkDestNoteFile)))
(* * pmi 8/7/87: Fixes bug %#630: prompt for filename doesn't append ".notefile.")

(* * Changed in NCCROSSFILELINKS)

(DEFINEQ

(NC.GetCrossFileLinkDestCard
  (LAMBDA (CrossFileLinkCard InterestedWindow Don'tOpenDestNoteFileFlg)
                                                             (* pmi: " 7-Aug-87 10:18")

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


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

(NC.OpenCrossFileLinkDestNoteFile
  (LAMBDA (DestNoteFile DestFileName InterestedWindow CrossFileLinkCard)
                                                             (* pmi: " 6-Aug-87 15:14")

          (* * If DestNoteFile is an open notefile, then fine. Otherwise get file names from user and keep trying to open 
	  until she gives up.)



          (* * rht 5/25/87: Minor change: no longer passes InterestedWindow to NC.OpenNoteFile.)



          (* * rht 6/3/87: Now calls new function NC.AskUserWithMenu. Added CrossFileLinkCard argument whose title is used to
	  construct Message.)



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



          (* * pmi 8/6/87: Replaced NC.AskUser with NC.DatabaseFileName when asking the user for a filename to try.
	  This insures that the filename ends in ".notefile")


    (OR InterestedWindow (NC.CoerceToInterestedWindow CrossFileLinkCard))
    (LET ((WasOpenPromptWindowFlg (NC.PromptWindowOpenP InterestedWindow)))
         (if (NCP.OpenNoteFileP DestNoteFile)
	     then DestNoteFile
	   else (LET ((MenuItems (QUOTE (Read/Write Read-Only Don't% Open))))
		       (for while (OR DestFileName (SETQ DestFileName
					      (NC.DatabaseFileName "File name to try opening: " NIL 
								     T T NIL InterestedWindow)))
			  do (LET ((Message (if (NC.ValidCardP CrossFileLinkCard)
						  then (CONCAT "Open " DestFileName 
								   " to look for '"
								   (NC.RetrieveTitle 
										CrossFileLinkCard)
								   "'?")
						else (CONCAT "OPEN " DestFileName "?")))
				     ReadOnlyOpenFlg)
				    (if (AND (SELECTQ (NC.AskUserWithMenu MenuItems Message 
										 InterestedWindow 
									   WasOpenPromptWindowFlg T)
							    (Read/Write (SETQ ReadOnlyOpenFlg NIL)
									T)
							    (Read-Only (SETQ ReadOnlyOpenFlg T))
							    (Don't% Open (RETURN NIL))
							    (RETURN NIL))
						 (NCP.OpenNoteFileP (SETQ DestNoteFile
									(NC.OpenNoteFile
									  (OR DestNoteFile 
										DestFileName)
									  NIL NIL NIL NIL NIL NIL NIL 
									  NIL NIL NIL NIL 
									  ReadOnlyOpenFlg))))
					then (RETURN DestNoteFile)
				      else (NC.PrintMsg InterestedWindow T "Couldn't open " 
							    DestFileName "." (CHARACTER 13))
					     (SETQ DestFileName (SETQ DestNoteFile NIL))
					     (if (NOT (NC.AskYesOrNo 
						     "Want to try opening a different notefile? "
									   " -- " "Yes" NIL 
									   InterestedWindow 
									   WasOpenPromptWindowFlg))
						 then (RETURN NIL))))))))))
)
(PUTPROPS PMIPATCH054 COPYRIGHT ("Xerox Corporation" 1987))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (635 7725 (NC.GetCrossFileLinkDestCard 645 . 4984) (NC.OpenCrossFileLinkDestNoteFile 
4986 . 7723)))))
STOP