(FILECREATED "16-Dec-86 19:23:09" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH175.;4 26926  

      changes to:  (FNS NC.MakeCrossFileLinkIconStandIn NC.MakeBrowserCard NC.UpdateBrowserCard)
		   (VARS RHTPATCH175COMS)

      previous date: "16-Dec-86 14:58:45" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH175.;1)


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

(PRETTYCOMPRINT RHTPATCH175COMS)

(RPAQQ RHTPATCH175COMS ((* * Fixes bug reported by Randy G whereby answering "no" to request to 
			     open Crossfilelink's notefile during browser creation causes break.)
			  (* * New function for NCCROSSFILELINKS)
			  (FNS NC.MakeCrossFileLinkIconStandIn)
			  (* * Change to NCBROWSERCARD)
			  (FNS NC.MakeBrowserCard NC.UpdateBrowserCard)
			  (* * Change to NCLINKS)
			  (FNS NC.MakeLink)))
(* * Fixes bug reported by Randy G whereby answering "no" to request to open Crossfilelink's 
notefile during browser creation causes break.)

(* * New function for NCCROSSFILELINKS)

(DEFINEQ

(NC.MakeCrossFileLinkIconStandIn
  (LAMBDA (RemoteCardTitle)                                  (* rht: "16-Dec-86 19:22")

          (* * Make a "fake" link imageobject as a standin for a real cross file link icon.)


    (DECLARE (GLOBALVARS NC.ExternalPutLinkIconImageFns))
    (IMAGEOBJCREATE (CONCAT "[[CrossFileLink to: " RemoteCardTitle "]]")
		      NC.ExternalPutLinkIconImageFns)))
)
(* * Change to NCBROWSERCARD)

(DEFINEQ

(NC.MakeBrowserCard
  (LAMBDA (Card Title NoDisplayFlg ParamList)                (* rht: "16-Dec-86 19:22")

          (* Make a browser card with id Card using root at RootID and the link following predictae specified by Predicate.
	  IF Root and/or ListOfLinkLabels not specified, ask the user.)



          (* * rht 8/3/84: Changed to call NC.AskLinkLabel with its ReverseLinkLabel parameter set to T.)



          (* * fgh 10/2/84 Changed Link Icons to be image objects in NodeLabel of Graph Npodes rather than annotations on 
	  graph nodes.)



          (* * rht 10/19/84: Fixed setting up of browser card's prop list in case NoDisplayFlg is T so we have no Window.
	  Now NC.MakeLinksLegend returns the label pairs.)



          (* * rht 11/27/84: Removed the WINDOWADDPROP call to put NC.GraphCardCloseFn on the CLOSEFN of the window.
	  This causes trouble. NC.QuitCard will get put on by NC.MakeNoteCard and that's enough.)



          (* * rht 1/3/85: Now puts a dummy region of the right size if the NoDisplayFlg is on.)



          (* * rht 1/15/85: Put hooks for AddNode, AddLink, etc. so editing graph edits underlying structure.)



          (* * rht 2/14/85: Added VerticalFlg and made BrowserSpecs get put on browser's proplist in all cases.)



          (* * rht 4/1/85: Now calls NC.AskBrowserSpecs with additional Don'tAskFlg in case of call from Programmer's 
	  interface.)



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



          (* * rht 2/7/86: Now gets browser format, etc. via fetch/set fns.)



          (* * rht 5/6/86: Took out call to NC.SetupTitleBarMenu.)



          (* * rht 5/8/86: Added calls to rig title bar properly.)



          (* * rht 7/10/86: Now passes ListOfLinkLabels to NC.AskBrowserSpecs.)



          (* * rht 9/19/86: Mod to above fix. Now calls NC.MakeNewCardWindow a new fn that creates window and hangs Card off 
	  windowprop.)



          (* * pmi 12/5/86: Modified message to NC.SelectNoteCards to mention SHIFT-selection. Also added GLOBALVARS 
	  statement.)



          (* * pmi 12/12/86: Removed obsolete ReturnLinksFlg argument in call to NC.SelectNoteCards.)



          (* * rht 12/16/86: Now checks that NC.MakeLink succeeded before creating a real link icon. If not, then make a 
	  standin for a cross file link icon.)


    (DECLARE (GLOBALVARS NC.SubBoxLinkLabel NC.BrowserContentsLinkLabel NC.SpecialBrowserSpecsFlg 
			     NC.*Graph*BrowserFormat NC.SelectingBrowserSourceMenu))
    (PROG ((RootCards (MKLIST (LISTGET ParamList (QUOTE ROOTCARDS))))
	     (ListOfLinkLabels (LISTGET ParamList (QUOTE LINKTYPES)))
	     (BrowserFormat (LISTGET ParamList (QUOTE FORMAT)))
	     (Depth (LISTGET ParamList (QUOTE DEPTH)))
	     (CardType (NC.RetrieveType Card))
	     Lattice RootNodes Window Graph SpecialBrowserSpecs BrowserSpecs DropVirtualNodesFlg)
	    (NC.ActivateCard Card)
	    (COND
	      ((NULL NoDisplayFlg)
		(SETQ Window (NC.MakeNewCardWindow Card (OR Title "Untitled")))
		(WINDOWADDPROP Window (QUOTE SHRINKFN)
				 (FUNCTION NC.GraphCardShrinkFn))))
	    (if (NULL RootCards)
		then (SETQ RootCards (if NoDisplayFlg
					     then (LIST NIL)
					   else (NC.SelectNoteCards NIL NIL 
								    NC.SelectingBrowserSourceMenu 
									Window 
		      "Please shift-select the Cards and/or Boxes the browser should start from."
									T))))
	    (COND
	      ((EQ RootCards (QUOTE CANCELLED))
		(NC.DeactivateCard Card)
		(CLOSEW Window)
		(RETURN)))
	    (NC.HoldTTYProcess)
	    (SETQ BrowserSpecs (NC.AskBrowserSpecs Window Card ListOfLinkLabels Depth 
						       BrowserFormat T (if (OR ParamList 
										   NoDisplayFlg)
									   then (QUOTE DONTASK))))
	    (COND
	      ((NULL BrowserSpecs)
		(NC.DeactivateCard Card)
		(CLOSEW Window)
		(RETURN)))
	    (SETQ ListOfLinkLabels (CAR BrowserSpecs))
	    (SETQ Depth (CADR BrowserSpecs))
	    (SETQ BrowserFormat (CADDR BrowserSpecs))    (* If user wants *GRAPH* format, i.e. virtual nodes 
							     eliminated, then set the flag)
	    (if (FMEMB NC.*Graph*BrowserFormat BrowserFormat)
		then (SETQ DropVirtualNodesFlg T))
	    (SETQ SpecialBrowserSpecs (COND
		(NC.SpecialBrowserSpecsFlg (NC.AskSpecialBrowserSpecs Window))
		(T (create SPECIALBROWSERSPECS))))
	    (OR NoDisplayFlg (NC.PrintMsg Window T (CHARACTER 13)
					      "Computing browser graph. Please wait. ..."))
                                                             (* Create new browser hash array)
	    (NC.GetBrowserHashArray Card)                  (* Compute lattice breakdth-first starting from 
							     roots.)
	    (SETQ Lattice (NC.GrowLinkLattice RootCards NIL ListOfLinkLabels Card Depth))
	    (SETQ RootNodes (for RootCard in RootCards collect (NC.GetBrowserNodeID Card 
											 RootCard)))
	    (OR NoDisplayFlg (WINDOWPROP Window (QUOTE NoteCardObject)
					     Card))

          (* * Link destination id information stored in NodeLabel field into a LinkIcon for display)


	    (for Node in Lattice bind NodeID eachtime (BLOCK)
	       do (replace (GRAPHNODE NODELABEL) of Node
		       with (LET ((NewLink (NC.MakeLink Window NC.BrowserContentsLinkLabel
							    (fetch (GRAPHNODE NODELABEL)
							       of Node)
							    Card NIL)))
			           (if NewLink
				       then (NC.MakeLinkIcon NewLink)
				     else (NC.MakeCrossFileLinkIconStandIn
					      (NCP.CardTitle (fetch (GRAPHNODE NODELABEL)
								  of Node))))))
                                                             (* Untouch each graph node so that next Recompute will
							     put fresh values on proplist.)
		    (SETQ NodeID (fetch (GRAPHNODE NODEID) of Node))
		    (NC.GraphNodeIDRemProp (NC.CoerceToGraphNodeID NodeID)
					     (QUOTE TouchedFlg))
		    (NC.GraphNodeIDRemProp (NC.CoerceToGraphNodeID NodeID)
					     (QUOTE VisitedFlg)))
	    (SETQ Graph (if (AND Lattice RootNodes)
			      then (LAYOUTGRAPH Lattice RootNodes (SUBST (QUOTE LATTICE)
									       
									  NC.*Graph*BrowserFormat 
									       BrowserFormat)
						    (fetch (SPECIALBROWSERSPECS Font) of 
									      SpecialBrowserSpecs)
						    (fetch (SPECIALBROWSERSPECS MotherD)
						       of SpecialBrowserSpecs)
						    (fetch (SPECIALBROWSERSPECS PersonalD)
						       of SpecialBrowserSpecs)
						    (fetch (SPECIALBROWSERSPECS FamilyD)
						       of SpecialBrowserSpecs))
			    else (create GRAPH)))
	    (NC.SetBrowserLinksLegend Card (NC.MakeLinksLegend Graph Window DropVirtualNodesFlg))
	    (OR NoDisplayFlg (NC.PrintMsg Window NIL "Done!"))
	    (NC.SetSubstance Card Graph)
	    (NC.SetBrowserLinkLabels Card (OR ListOfLinkLabels (LIST NC.SubBoxLinkLabel)))
	    (NC.SetBrowserRoots Card RootCards)
	    (NC.SetBrowserFormat Card BrowserFormat)
	    (NC.SetBrowserDepth Card Depth)
	    (NC.SetSpecialBrowserSpecs Card SpecialBrowserSpecs)
	    (COND
	      (NoDisplayFlg (RETURN Card)))
	    (WINDOWPROP Window (QUOTE GRAPH)
			  Graph)
	    (NC.InstallTitleBarLeftMenu Window CardType)
	    (NC.InstallTitleBarMiddleMenu Window CardType)
	    (NC.RelayoutBrowserCard Window)
	    (RETURN Window))))

(NC.UpdateBrowserCard
  (LAMBDA (Window DontCheckOpInProgressFlg)                  (* rht: "16-Dec-86 19:00")

          (* * rht 10/14/84: Added call to DETACHALLWINDOWS to close any existing links legend window and prompt window.
	  Also added call to NC.MakeLinksLegend to make a new attached legend menu.)



          (* * rht 1/15/85: Put hooks for AddNode, AddLink, etc. so editing graph edits underlying structure.)



          (* * rht 2/14/85: Added ability to respecify roots and link labels before recomputing graph.)



          (* * rht 3/8/85: Modified to use new browser props stored on card's proplist as of release 1.2.)



          (* * rht 3/17/85: Now takes OnlyLayoutFlg argument. If set, then don't recompute lattice or ask about root nodes.)



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



          (* * kirk 23Jan86 Changed to use NC.AskYesOrNo)



          (* * rht 2/7/86: Now gets and sets browser format, etc. via fetch/set fns.)



          (* * rht 3/7/86: Now only closes the Links legend menu attached window.)



          (* * rht 6/10/86: Moved code to delete links legend menu and code to make new browser hash array to after 
	  questioning user about respecifying roots.)



          (* * rht 11/1/86: Added NC.ProtectedCardOperation wrapper and check for ops in progress.)



          (* * pmi 12/5/86: Modified message to NC.SelectNoteCards to mention SHIFT-selection.)



          (* * pmi 12/12/86: Removed obsolete ReturnLinksFlg argument in call to NC.SelectNoteCards.)



          (* * rht 12/16/86: Now checks that NC.MakeLink succeeded before creating a real link icon. If not, then make a 
	  standin for a cross file link icon.)


    (LET ((Card (NC.CoerceToCard Window))
	  OperationInProgress)

          (* * if in the middle of some other operation, get out of here.)


         (if (AND (NULL DontCheckOpInProgressFlg)
		      (SETQ OperationInProgress (NC.OperationInProgress Card)))
	     then (NC.PrintOperationInProgressMsg Window (QUOTE Recompute% Browser% Card)
						      OperationInProgress)
		    NIL
	   else
	    (NC.ProtectedCardOperation
	      Card Recompute% Browser% Card
	      (PROG (LinkLabels RootCards RootNodes Lattice LinkIcon Graph GraphNodes NodeLabel 
				  BrowserSpecs BrowserFormat DropVirtualNodesFlg Depth 
				  SpecialBrowserSpecs OldLabelNodes OldRootCards)
		      (SETQ RootCards (NC.FetchBrowserRoots Card))
		      (SETQ LinkLabels (NC.FetchBrowserLinkLabels Card))
		      (SETQ BrowserFormat (OR (NC.FetchBrowserFormat Card)
						  (QUOTE (LATTICE))))
                                                             (* If user wants *GRAPH* format, i.e. virtual nodes 
							     eliminated, then set the flag)
		      (if (FMEMB NC.*Graph*BrowserFormat BrowserFormat)
			  then (SETQ DropVirtualNodesFlg T))
		      (SETQ Depth (OR (NC.FetchBrowserDepth Card)
					  999999))
		      (SETQ SpecialBrowserSpecs (OR (NC.FetchSpecialBrowserSpecs Card)
							(create SPECIALBROWSERSPECS)))
		      (SETQ GraphNodes (fetch (GRAPH GRAPHNODES) of (SETQ Graph
									    (WINDOWPROP
									      Window
									      (QUOTE GRAPH)))))
                                                             (* Get new roots.)
		      (if (OR (NULL RootCards)
				  (NC.AskYesOrNo "Want to respecify roots? " "--" "No" T Window T 
						   NIL))
			  then (NC.BrowserFlipRoots Window Card GraphNodes (SETQ OldRootCards 
							  RootCards))
				 (SETQ RootCards (NC.SelectNoteCards NIL NIL 
								    NC.SelectingBrowserSourceMenu 
									 Window (CONCAT
									   
		      "Please shift-select the Cards and/or Boxes the browser should start from."
									   (CHARACTER 13)
									   
							       "(Current roots are highlighted.)")
									 T))
				 (NC.BrowserFlipRoots Window Card GraphNodes OldRootCards)
				 (COND
				   ((EQ RootCards (QUOTE CANCELLED))
				     (RETURN))))           (* Get rid of the links legend menu attached window.)
		      (for Win in (ATTACHEDWINDOWS Window) when (WINDOWPROP Win
										      (QUOTE 
										  LINKSLEGENDWINP))
			 do (DETACHWINDOW Win)
			      (CLOSEW Win))                (* Smash the current hash array, putting a fresh one 
							     in its place.)
		      (NC.GetBrowserHashArray Card)
		      (NC.PrintMsg Window T (CHARACTER 13)
				     "Computing browser graph. Please wait. ...")
                                                             (* Compute lattice breadth-first from the roots.)
		      (SETQ Lattice (NC.GrowLinkLattice RootCards NIL LinkLabels Card Depth))
		      (SETQ RootNodes (for RootCard in RootCards collect (
									      NC.GetBrowserNodeID
										   Card RootCard)))
		      (NC.SetPropListDirtyFlg Card T)      (* Remove all links that are in the old browser graph 
							     but not in the new one)
		      (for Node in GraphNodes bind NodeID NodeLabel eachtime (BLOCK)
			 unless (FASSOC (OR (CAR (SETQ NodeID (fetch (GRAPHNODE NODEID)
									   of Node)))
						  NodeID)
					    Lattice)
			 do (COND
				((NC.LinkIconImageObjP (SETQ NodeLabel (fetch (GRAPHNODE 
											NODELABEL)
									      of Node)))
				  (NC.DeleteLink (NC.FetchLinkFromLinkIcon NodeLabel)
						   T T))
				((STRINGP NodeLabel)       (* Collect the label nodes from the old browser.)
				  (SETQ OldLabelNodes (CONS Node OldLabelNodes)))))
                                                             (* Create Links for all nodes in the new browser graph
							     but not in the old one.)
		      (for Node in Lattice bind NodeID OldNode eachtime (BLOCK)
			 do (SETQ NodeID (fetch (GRAPHNODE NODEID) of Node))
			      (COND
				((SETQ OldNode (FASSOC NodeID GraphNodes))
				  (replace (GRAPHNODE NODELABEL) of Node
				     with (fetch (GRAPHNODE NODELABEL) of OldNode)))
				(T (replace (GRAPHNODE NODELABEL) of Node
				      with (LET ((NewLink (NC.MakeLink Window 
								      NC.BrowserContentsLinkLabel
									   (fetch (GRAPHNODE 
											NODELABEL)
									      of Node)
									   Card NIL)))
					          (if NewLink
						      then (NC.MakeLinkIcon NewLink)
						    else (NC.MakeCrossFileLinkIconStandIn
							     (NCP.CardTitle (fetch (GRAPHNODE
											 NODELABEL)
										 of Node))))))))
                                                             (* Untouch each graph node so that next Recompute will
							     put fresh values on proplist.)
			      (NC.GraphNodeIDRemProp NodeID (QUOTE TouchedFlg))
			      (NC.GraphNodeIDRemProp NodeID (QUOTE VisitedFlg)))
                                                             (* Throw in the label nodes from the old browser.)
		      (SETQ Lattice (NCONC Lattice OldLabelNodes))
                                                             (* For each old label node, take away nonexistent 
							     fromnodes and save the label nodes that no longer have
							     any from nodes.)
		      (for OldLabelNode in OldLabelNodes eachtime (BLOCK)
			 do (replace (GRAPHNODE FROMNODES) of OldLabelNode
				 with (for FromNodeID in (fetch (GRAPHNODE FROMNODES)
								  of OldLabelNode)
					   bind FromNode eachtime (BLOCK)
					   when (SETQ FromNode (FASSOC FromNodeID Lattice))
					   collect         (* If the From node isn't a label node, then add to 
							     its Tonode list.)
						     (if (NC.LinkIconImageObjP
							     (fetch (GRAPHNODE NODELABEL)
								of FromNode))
							 then (replace (GRAPHNODE TONODES)
								   of FromNode
								   with (CONS
									    (fetch (GRAPHNODE
										       NODEID)
									       of OldLabelNode)
									    (fetch (GRAPHNODE
										       TONODES)
									       of FromNode))))
						     FromNodeID))
                                                             (* For the old label node's ToNodes, just need to 
							     remove any for ToNodes that no longer exist.)
			      (replace (GRAPHNODE TONODES) of OldLabelNode
				 with (for ToNodeID in (fetch (GRAPHNODE TONODES)
								of OldLabelNode)
					   bind ToNode eachtime (BLOCK)
					   when (SETQ ToNode (FASSOC ToNodeID Lattice))
					   collect         (* If the To node isn't a label node, then add to its 
							     FromNode list.)
						     (if (NC.LinkIconImageObjP
							     (fetch (GRAPHNODE NODELABEL)
								of ToNode))
							 then (replace (GRAPHNODE FROMNODES)
								   of ToNode
								   with (CONS
									    (fetch (GRAPHNODE
										       NODEID)
									       of OldLabelNode)
									    (fetch (GRAPHNODE
										       FROMNODES)
									       of ToNode))))
						     ToNodeID)))
                                                             (* Layout graph, including as roots any non-virtual 
							     nodes with no from nodes to avoid disconnected 
							     graphs.)
		      (SETQ Graph (if (AND Lattice RootNodes)
					then (LAYOUTGRAPH
						 Lattice
						 (for Node in Lattice bind NodeID
						    eachtime (BLOCK)
							       (SETQ NodeID
								 (OR (NC.CoerceToGraphNodeID
									 Node)
								       (fetch (GRAPHNODE NODEID)
									  of Node)))
						    when (OR (FMEMB NodeID RootNodes)
								 (NULL (fetch (GRAPHNODE 
											FROMNODES)
									    of Node)))
						    collect NodeID)
						 (SUBST (QUOTE LATTICE)
							  NC.*Graph*BrowserFormat BrowserFormat)
						 (fetch (SPECIALBROWSERSPECS Font) of 
									      SpecialBrowserSpecs)
						 (fetch (SPECIALBROWSERSPECS MotherD) of 
									      SpecialBrowserSpecs)
						 (fetch (SPECIALBROWSERSPECS PersonalD)
						    of SpecialBrowserSpecs)
						 (fetch (SPECIALBROWSERSPECS FamilyD) of 
									      SpecialBrowserSpecs))
				      else (create GRAPH)))
                                                             (* Build links legend and fix up TONODES in the 
							     graph.)
		      (NC.SetBrowserLinksLegend Card (NC.MakeLinksLegend Graph Window 
									     DropVirtualNodesFlg))
		      (NC.SetBrowserRoots Card RootCards)
		      (NC.SetBrowserDepth Card Depth)
		      (WINDOWPROP Window (QUOTE GRAPH)
				    Graph)
		      (NC.RelayoutBrowserCard Window T)))))))
)
(* * Change to NCLINKS)

(DEFINEQ

(NC.MakeLink
  (LAMBDA (Window LinkLabel DestinationCard SourceCard DisplayMode AnchorMode Message NoDisplayFlg 
		  LinkToInsertAfter CrossFileLinksMode)      (* rht: "16-Dec-86 14:53")

          (* * Make a link from (OR Window SourceCard) to DestinationCard with linklabel of LinkLabel)



          (* * rht 1/12/85: If need to create a new card, then now shows card type menu near window of SourceID.)



          (* * rht 1/13/85: Added extra args Message and NoDisplayFlg.)



          (* * rht 3/26/85: Added LinkToInsertAfter arg which should be NIL or a link to insert the new To link after.
	  If NIL, then insert at front of ToLinks.)



          (* * kirk 9/23/85: took out GETPROMPTWINDOW call for asknotecardtype)



          (* * kirk: 14Nov85: changed NC.CoerceToID to to NC.CoerceToCard)



          (* * fgh 11/16/85 Changed from PROG to LET and used COND to contyrol returnmed value.)



          (* * fgh 2/5/86 Changed call DefaultLinkDisplayMode to FetchLinkDisplayMode)



          (* * fgh 6/5/86 Now calls AskLinkLabel if LinkLabel arg is NIL)



          (* * rht 7/4/86: Added check for readonly card.)



          (* * kef 7/17/86: Added calls to grab the write permission on the appropriate card parts.)



          (* * kef 7/22/86: Saves the links on the Destination Card now right away, while still holding onto the FROMLINKS 
	  write lock.)



          (* * fgh 8/30/86 Adpated to use NC.IfCardPartNotBusy.)



          (* * rht 9/29/86: Tossed Ken's call to NC.PutFromLinks; It was the cause of too many nasty breaks.
	  Also made syntactic fixes.)



          (* * rht 10/4/86: Now handles cross file links. New arg CrossFileLinksMode determines whether cross-file link will 
	  be two-way, i.e. will destination card know it's being linked to.)



          (* * rht 11/10/86: Now creates new crossfile link if Destination card is a CrossFileLink card that we didn't just 
	  create.)



          (* * rht 11/14/86: Now checks if non-nil DestinationCard before trying to do cross-filelink stuff.)



          (* * pmi 12/5/86: Modified message to NC.SelectNoteCards to mention SHIFT-selection.)



          (* * rht 12/9/86: Throws out JustCreatedFlg marker stuff.)



          (* * pmi 12/12/86: Removed obsolete ReturnLinksFlg argument in call to NC.SelectNoteCards.)



          (* * rht 12/16/86: Fixed bug whereby electing not to open notefile containing crossfilelink dest card caused 
	  break.)


    (DECLARE (GLOBALVARS NC.SelectingSingleCardMenu NC.NewCrossFileLinksTwoWayFlg))
    (OR SourceCard (SETQ SourceCard (NC.CoerceToCard Window)))
    (AND (NC.CheckForNotReadOnly SourceCard Window "Can't make links in ")
	   (LET (Link Type)
	        (OR Window (SETQ Window (NC.FetchWindow SourceCard)))
	        (OR Message (SETQ Message "Please shift-select the Card or Box to be linked to."))
	        (OR LinkLabel (SETQ LinkLabel (NC.AskLinkLabel Window NIL NIL T NIL)))
	        (OR DestinationCard (SETQ DestinationCard
			(NC.SelectNoteCards T (FUNCTION (LAMBDA (Card)
						  (COND
						    ((NOT (NC.SameCardP Card SourceCard))
						      T)
						    (T (NC.PrintMsg Window T 
							     "A Card/Box cannot link to itself. "
								      (CHARACTER 13)
								      "Selection ignored."
								      (CHARACTER 13))
						       NIL))))
					      NC.SelectingSingleCardMenu SourceCard Message)))
	        (if (EQ DestinationCard (QUOTE *New% Card*))
		    then (SETQ DestinationCard (AND (SETQ Type (NC.AskNoteCardType
							      (WINDOWREGION Window)))
							  (NC.CoerceToCard
							    (NC.MakeNoteCard Type
									       (fetch (Card 
											 NoteFile)
										  of SourceCard)
									       NIL NoDisplayFlg)))))

          (* * If we're trying to link to a CrossFileLink card, then check whether card was just created.
	  If so, then it's the first link, otherwise we make a new CrossFileLink.)


	        (AND DestinationCard (NC.CrossFileLinkCardP DestinationCard)
		       (SETQ DestinationCard (NC.GetCrossFileLinkDestCard DestinationCard))
		       (NC.SetUserDataProp DestinationCard (QUOTE JustCreatedFlg)
					     NIL))
	        (if DestinationCard
		    then (NC.IfCardPartNotBusy
			     DestinationCard
			     (QUOTE FROMLINKS)
			     (NC.IfCardPartNotBusy SourceCard (QUOTE TOLINKS)

          (* * If have cross-file link, then make two new crossfilelink cards, one per notefile. Make global link over there 
	  from crossfilelink card to DestinationCard and local link here from SourceCard to crossfilelink card.)


						   (if (NOT (NC.SameNoteFileP
								  (fetch (Card NoteFile)
								     of SourceCard)
								  (fetch (Card NoteFile)
								     of DestinationCard)))
						       then
							(LET ((CrossFileLinksTwoWayFlg
								(OR (EQ CrossFileLinksMode
									    (QUOTE TWOWAY))
								      (AND (NULL 
									       CrossFileLinksMode)
									     
								    NC.NewCrossFileLinksTwoWayFlg))))
							     (if CrossFileLinksTwoWayFlg
								 then (NC.MakeGlobalLink
									  Window LinkLabel 
									  DestinationCard
									  (
								       NC.CreateCrossFileLinkCard
									    DestinationCard 
									    SourceCard T)
									  DisplayMode))
							     (SETQ DestinationCard
							       (NC.CreateCrossFileLinkCard 
										       SourceCard 
										  DestinationCard 
									  CrossFileLinksTwoWayFlg))))
						   (SETQ Link (create Link
									  UID ←(NC.MakeUID)
									  SourceCard ← SourceCard
									  DestinationCard ← 
									  DestinationCard
									  AnchorMode ← AnchorMode
									  Label ← LinkLabel
									  DisplayMode ←(OR
									    DisplayMode
									    (NC.FetchLinkDisplayMode
									      SourceCard))))
						   (NC.AddToLink Link LinkToInsertAfter)
						   (NC.AddFromLink Link)
						   Link))
		  else NIL)))))
)
(PUTPROPS RHTPATCH175 COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (1001 1430 (NC.MakeCrossFileLinkIconStandIn 1011 . 1428)) (1467 20532 (
NC.MakeBrowserCard 1477 . 9300) (NC.UpdateBrowserCard 9302 . 20530)) (20563 26844 (NC.MakeLink 20573
 . 26842)))))
STOP