(FILECREATED "16-Dec-86 22:18:07" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH178.;3 26568  

      changes to:  (FNS NC.LinkIconWhenCopiedFn NC.LinkIconWhenMovedFn)
		   (VARS RHTPATCH178COMS)

      previous date: "16-Dec-86 22:12:52" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH178.;1)


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

(PRETTYCOMPRINT RHTPATCH178COMS)

(RPAQQ RHTPATCH178COMS ((* * Change to NCCROSSFILELINKS)
			  (FNS NC.GetCrossFileLinkDestCard)
			  (* * Change to NCLINKS)
			  (FNS NC.MakeLink NC.LinkIconWhenCopiedFn NC.LinkIconWhenMovedFn)))
(* * Change to NCCROSSFILELINKS)

(DEFINEQ

(NC.GetCrossFileLinkDestCard
  (LAMBDA (CrossFileLinkCard InterestedWindow)               (* rht: "16-Dec-86 22:01")

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


    (LET ((Title (NC.FetchTitle CrossFileLinkCard))
	  (SourceNoteFile (fetch (Card NoteFile) of CrossFileLinkCard))
	  Substance DestNoteFileUID DestFileHint DestCardUID DestNoteFile DestFileName WasOpenFlg)
         (OR (WINDOWP InterestedWindow)
	       (SETQ InterestedWindow (WFROMMENU (fetch (NoteFile Menu) of SourceNoteFile))))
         (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))
         (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))))))
    ))
)
(* * Change to NCLINKS)

(DEFINEQ

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

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



          (* * rht 12/16/86: Now passes Window down to NC.GetCrossFileLinkDestCard.)


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

(NC.LinkIconWhenCopiedFn
  (LAMBDA (ImageObject ToWindowStream FromTextStream ToTextStream)
                                                             (* rht: "16-Dec-86 22:17")

          (* * Called when copying a link icon from FromTextStream to ToWindowStream. Sets the necessary link information up 
	  for card corresponding to ToWindowStream.)



          (* * rht 11/18/84: Major hacking. Now checks for all sorts of illegal cases. Either goes ahead with copy, converts 
	  link type to "Unspecified", or deletes the new "invisible" link. The latter will change when imageobj fns can 
	  return DON'T.)



          (* * rht 12/12/84: now does RETFROM instead of adding processes to delete imageobj's. This is cleaner, but still 
	  ugly.)



          (* * rht 3/25/85: Fixed to handle copies within a sketch card. That is indicated by nullity of the two textstream 
	  args.)



          (* * rht 3/24/86: Changed call to NC.CoerceToID to NC.CoerceToCard)



          (* * fgh 6/30/86 Now ERROR! out of attempt to copy between NoteFiles)



          (* * rht 7/14/86: Reversed order of tests for WINDOWP and TEXTSTREAMP in computation of NewSourceCard.)



          (* * rht 8/11/86: Now only resets NewSourceCard if it was NIL so that copies to a sketch will work.)



          (* * rht 10/5/86: Undid change fgh 6/30/86: now allows copies of links across notefiles. Also handles illegal 
	  copies differently. Rather than RETFROM'ing or ERROR!'ing, it puts in a DELETE ME imageobj.)



          (* * rht 12/16/86: Now passes Window to NC.GetCrossFileLinkDestCard.)


    (DECLARE (GLOBALVARS NC.CopyCrossFileLinksMode NC.DELETEMEImageObjDatum NC.SystemLinkLabels 
			     NC.UnspecifiedLinkLabel))
    (LET ((Link (NC.FetchLinkFromLinkIcon ImageObject))
	  (ImageObjectCopy (IMAGEOBJPROP ImageObject (QUOTE ImageObjectCopy)))
	  (InTEditCopyFlg (COND
			    ((STKPOS (QUOTE TEDIT.COPY))
			      T)))
	  (Window (AND ToWindowStream (WFROMDS ToWindowStream T)))
	  SourceCard DestinationCard NewSourceCard NewLabel NewDisplayMode OldDisplayMode Label 
	  InsertPos IllegalCopyFlg)
         (SETQ Label (fetch (Link Label) of Link))
         (SETQ SourceCard (fetch (Link SourceCard) of Link))
         (SETQ DestinationCard (fetch (Link DestinationCard) of Link))
         (SETQ OldDisplayMode (fetch (Link DisplayMode) of Link))
         (SETQ NewSourceCard (COND
	     ((TEXTSTREAMP ToTextStream)
	       (NC.CoerceToCard ToTextStream))
	     ((WINDOWP Window)
	       (NC.CoerceToCard Window))))
         (COND
	   ((AND (NULL NewSourceCard)
		   (NULL FromTextStream)
		   (NULL ToTextStream))                    (* We must be moving within a sketch.)
	     (SETQ NewSourceCard SourceCard))
	   ((TEXTSTREAMP ToTextStream)                     (* If it's a text copy, then compute position to 
							     insert link at.)
	     (SETQ InsertPos (NC.CharPosFromTextObject (TEXTOBJ ToTextStream)))))
         (COND
	   ((NULL NewSourceCard)                           (* Trying to copy to a non NoteCard stream)
	     (NC.PrintMsg Window NIL (CONCAT "Tried to copy a NoteCards link icon" 
						 " to a non-NoteCards stream."
						 (CHARACTER 13)))
	     (SETQ IllegalCopyFlg T))
	   ((NULL (NC.LinksSupportedP NewSourceCard (QUOTE (Local))))
	     (NC.PrintMsg Window NIL (CONCAT "Tried to copy a NoteCards link icon" 
						 " to a NoteCard that"
						 " does not support links!!."
						 (CHARACTER 13)))
	     (SETQ IllegalCopyFlg T))
	   ((AND (FMEMB Label (QUOTE (FiledCard SubBox)))
		   (NEQ (NC.RetrieveType NewSourceCard)
			  (QUOTE FileBox)))                (* Copy from filebox to non-filebox.)
	     (NC.PrintMsg Window NIL (CONCAT 
				       "Tried to copy filedcard or subbox link to a non-filebox."
						 (CHARACTER 13)
						 "Link type of copy set to 'Unspecified'."
						 (CHARACTER 13)))
	     (SETQ NewLabel NC.UnspecifiedLinkLabel)
	     (SETQ NewDisplayMode (create LINKDISPLAYMODE
				       copying OldDisplayMode SHOWTITLEFLG ← T SHOWLINKTYPEFLG ← T))
	     )
	   ((AND (NEQ (NC.RetrieveType SourceCard)
			  (QUOTE FileBox))
		   (EQ (NC.RetrieveType NewSourceCard)
			 (QUOTE FileBox)))                 (* Copy from non-filebox to filebox.)
	     (NC.PrintMsg Window NIL (CONCAT "Can't copy links from non-filebox to filebox."
						 (CHARACTER 13)
						 "Try using 'PutCardsHere'."
						 (CHARACTER 13)))
	     (SETQ IllegalCopyFlg T))
	   ((AND (FMEMB Label (QUOTE (FiledCard SubBox)))
		   (EQ NewSourceCard SourceCard))          (* Copy within same filebox.)
	     (NC.PrintMsg Window NIL (CONCAT 
					  "Can't copy links within a FileBox.  Try move instead."
						 (CHARACTER 13)))
	     (SETQ IllegalCopyFlg T))
	   ((AND (EQ (NC.RetrieveType NewSourceCard)
			 (QUOTE FileBox))
		   (for Link1 in (NC.FetchToLinks NewSourceCard)
		      thereis (AND (NC.ChildLinkP Link1)
				       (EQ DestinationCard (fetch (Link DestinationCard)
								of Link1)))))
                                                             (* Copy to a filebox already containing this child.)
	     (NC.PrintMsg Window NIL (CONCAT (NC.RetrieveTitle DestinationCard)
						 " not copied: already appears as a child of "
						 (NC.RetrieveTitle NewSourceCard)
						 (CHARACTER 13)))
	     (SETQ IllegalCopyFlg T))
	   ((AND (EQ Label (QUOTE SubBox))
		   (OR (EQ NewSourceCard DestinationCard)
			 (NOT (NC.NotDaughterP DestinationCard NewSourceCard
						   (FUNCTION NC.ChildLinkP)))))
                                                             (* Copy to a filebox causes a cycle.)
	     (NC.PrintMsg Window NIL (CONCAT "Couldn't copy " Link " because of subbox cycle."
						 (CHARACTER 13)))
	     (SETQ IllegalCopyFlg T))
	   ((AND (FMEMB Label NC.SystemLinkLabels)
		   (NOT (FMEMB Label (QUOTE (FiledCard SubBox))))
		   (NEQ NewSourceCard SourceCard))         (* Copy of system link outside of own card.)
	     (NC.PrintMsg Window NIL (CONCAT "Tried to copy system link." (CHARACTER 13)
						 "Link type of copy set to 'Unspecified'."
						 (CHARACTER 13)))
	     (SETQ NewLabel NC.UnspecifiedLinkLabel)
	     (SETQ NewDisplayMode (create LINKDISPLAYMODE
				       copying OldDisplayMode SHOWTITLEFLG ← T SHOWLINKTYPEFLG ← T))
	     )
	   ((NC.CrossFileLinkCardP DestinationCard)        (* Copy of a cross-file link.)
	     (if (NOT (NC.ActiveCardP DestinationCard))
		 then (NC.GetNoteCard DestinationCard))
                                                             (* If it's to be two-way, then make a fresh 
							     CrossFileLinkCard.)
	     (if (OR (EQ NC.CopyCrossFileLinksMode (QUOTE TWOWAY))
			 (AND (NULL NC.CopyCrossFileLinksMode)
				NC.NewCrossFileLinksTwoWayFlg))
		 then (SETQ DestinationCard (NC.GetCrossFileLinkDestCard DestinationCard Window)
			  ))
	     (OR DestinationCard (SETQ IllegalCopyFlg T))))
         (if IllegalCopyFlg
	     then (IMAGEOBJPROP ImageObjectCopy (QUOTE OBJECTDATUM)
				    NC.DELETEMEImageObjDatum)
		    (NC.SetUserDataProp SourceCard (QUOTE NeedsCleaningFlg)
					  T)
	   else (NC.FillInLinkIcon ImageObjectCopy (OR NewLabel Label)
				       DestinationCard NewSourceCard (OR NewDisplayMode 
									   OldDisplayMode)
				       (NC.LinkAtCharPos InsertPos ToTextStream)
				       NC.CopyCrossFileLinksMode))
         (IMAGEOBJPROP ImageObject (QUOTE ImageObjectCopy)
			 NIL))))

(NC.LinkIconWhenMovedFn
  (LAMBDA (ImageObject ToWindowStream FromTextStream ToTextStream)
                                                             (* rht: "16-Dec-86 22:12")

          (* * Called when moving a link icon from FromTextStream to ToWindowStream. Sets the necessary link information up 
	  for card corresponding to ToWindowStream.)



          (* * rht 11/18/84: Major hacking. Now checks for all sorts of illegal cases. Either goes ahead with move, converts 
	  link type to "Unspecified", or deletes the new "invisible" link. The code is very similar to 
	  NC.LinkIconWhenCopiedFn except that within-filebox moves are allowed. Also when aborting a move, we must insert a 
	  copy of the link back to take the place of the deleted original. This will all change when imageobj fns can return 
	  DON'T.)



          (* * rht 12/12/84: Now just RETFROM's rather than doing the addprocess stuff. Should be cleaner, but still ugly.)



          (* * kirk 15Nov85: deleted use of PSA.Database)



          (* * rht 3/24/86: Changed call to NC.CoerceToID to NC.CoerceToCard)



          (* * kirk 24Mar86: added Dave Newman patch to avoid duplicate links in sketch cards)



          (* * rht 7/14/86: Reversed order of tests for WINDOWP and TEXTSTREAMP in computation of NewSourceCard.)



          (* * rht 8/11/86: Now only resets NewSourceCard if it was NIL so that moves to a sketch will work.
	  Now checks if SourceCard = NewSourceCard in which case we're moving within a card. Don't make a new link in that 
	  case.)



          (* * rht 10/5/86: Undid change fgh 6/30/86: now allows copies of links across notefiles.)



          (* * rht 11/13/86: Removed "tsk, tsk" messages.)



          (* * rht 12/16/86: Fixed calls to NC.PrintMsg to use Window arg.)


    (DECLARE (GLOBALVARS NC.SystemLinkLabels NC.UnspecifiedLinkLabel))
    (LET (Label (Link (NC.FetchLinkFromLinkIcon ImageObject))
		SourceCard DestinationCard NewSourceCard NewLabel NewDisplayMode OldDisplayMode
		(Window (AND ToWindowStream (WFROMDS ToWindowStream T)))
		InsertPos)
         (SETQ Label (fetch (Link Label) of Link))
         (SETQ NewSourceCard (COND
	     ((TEXTSTREAMP ToTextStream)
	       (NC.CoerceToCard ToTextStream))
	     ((WINDOWP Window)
	       (NC.CoerceToCard Window))))
         (SETQ SourceCard (fetch (Link SourceCard) of Link))
         (SETQ DestinationCard (fetch (Link DestinationCard) of Link))
         (SETQ OldDisplayMode (fetch (Link DisplayMode) of Link))
         (COND
	   ((AND (NULL NewSourceCard)
		   (NULL FromTextStream)
		   (NULL ToTextStream))                    (* We must be moving within a sketch.)
	     (SETQ NewSourceCard SourceCard))
	   ((TEXTSTREAMP ToTextStream)                     (* If it's a text copy, then compute position to 
							     insert link at.)
	     (SETQ InsertPos (NC.CharPosFromTextObject (TEXTOBJ ToTextStream)))))
         (COND
	   ((NULL NewSourceCard)                           (* Trying to copy to a non NoteCard stream)
	     (NC.PrintMsg Window NIL (CONCAT "Tried to move a NoteCards link icon" 
						 " to a non-NoteCards stream!!."
						 (CHARACTER 13)))
	     (RETFROM (QUOTE TEDIT.MOVE)
			NIL T))
	   ((NULL (NC.LinksSupportedP NewSourceCard (QUOTE (Local))))
	     (NC.PrintMsg Window NIL (CONCAT "Tried to move a NoteCards link icon" 
						 " to a NoteCard that"
						 " does not support links!!."
						 (CHARACTER 13)))
	     (RETFROM (QUOTE TEDIT.MOVE)
			NIL T))
	   ((AND (FMEMB Label (QUOTE (FiledCard SubBox)))
		   (NEQ (NC.RetrieveType NewSourceCard)
			  (QUOTE FileBox)))                (* Move from filebox to non-filebox.)
	     (NC.PrintMsg Window NIL (CONCAT 
				       "Tried to move filedcard or subbox link to a non-filebox."
						 (CHARACTER 13)
						 "Link type of copy set to 'Unspecified'."
						 (CHARACTER 13)))
	     (SETQ NewLabel NC.UnspecifiedLinkLabel)
	     (SETQ NewDisplayMode (create LINKDISPLAYMODE
				       copying OldDisplayMode SHOWTITLEFLG ← T SHOWLINKTYPEFLG ← T))
	     )
	   ((AND (NEQ (NC.RetrieveType SourceCard)
			  (QUOTE FileBox))
		   (EQ (NC.RetrieveType NewSourceCard)
			 (QUOTE FileBox)))                 (* Move from non-filebox to filebox.)
	     (NC.PrintMsg Window NIL (CONCAT "Can't move links from non-filebox to filebox."
						 (CHARACTER 13)
						 "Try using PutCardsHere."
						 (CHARACTER 13)))
	     (RETFROM (QUOTE TEDIT.MOVE)
			NIL T))
	   ((AND (EQ (NC.RetrieveType NewSourceCard)
			 (QUOTE FileBox))
		   (NEQ NewSourceCard SourceCard)
		   (for Link1 in (NC.FetchToLinks NewSourceCard)
		      thereis (AND (NC.ChildLinkP Link1)
				       (EQ DestinationCard (fetch (Link DestinationCard)
								of Link1)))))
                                                             (* Move to a filebox already containing this child.)
	     (NC.PrintMsg Window NIL (CONCAT (NC.RetrieveTitle DestinationCard)
						 " not moved: already appears as a child of "
						 (NC.RetrieveTitle NewSourceCard)
						 (CHARACTER 13)))
	     (RETFROM (QUOTE TEDIT.MOVE)
			NIL T))
	   ((AND (EQ Label (QUOTE SubBox))
		   (NEQ NewSourceCard SourceCard)
		   (OR (EQ NewSourceCard DestinationCard)
			 (NOT (NC.NotDaughterP DestinationCard NewSourceCard
						   (FUNCTION NC.ChildLinkP)))))
                                                             (* Move to a filebox causes a cycle.)
	     (NC.PrintMsg Window NIL (CONCAT "Couldn't move " Link " because of subbox cycle."
						 (CHARACTER 13)))
	     (RETFROM (QUOTE TEDIT.MOVE)
			NIL T))
	   ((AND (FMEMB Label NC.SystemLinkLabels)
		   (NOT (FMEMB Label (QUOTE (FiledCard SubBox))))
		   (NEQ NewSourceCard SourceCard))         (* Move of system link outside of own card.)
	     (NC.PrintMsg Window NIL (CONCAT "Tried to copy system link." (CHARACTER 13)
						 "Link type of copy set to 'Unspecified'."
						 (CHARACTER 13)))
	     (SETQ NewLabel NC.UnspecifiedLinkLabel)
	     (SETQ NewDisplayMode (create LINKDISPLAYMODE
				       copying OldDisplayMode SHOWTITLEFLG ← T SHOWLINKTYPEFLG ← T))
	     ))
         (if (EQ SourceCard NewSourceCard)
	     then                                          (* Moving within a card, so just reposition Link in 
							     ToLinks list.)
		    (AND (NC.TEditBasedP SourceCard)
			   (IMAGEOBJPROP ImageObject (QUOTE LinkBeingMovedWithinCard)
					   Link))
		    (NC.AddToLink Link (NC.LinkAtCharPos InsertPos ToTextStream)
				    T)
	   else (IMAGEOBJPROP ImageObject (QUOTE LinkBeingMoved)
				  Link)
		  (NC.FillInLinkIcon ImageObject (OR NewLabel Label)
				       DestinationCard NewSourceCard (OR NewDisplayMode 
									   OldDisplayMode)
				       (NC.LinkAtCharPos InsertPos ToTextStream))))))
)
(PUTPROPS RHTPATCH178 COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (616 4656 (NC.GetCrossFileLinkDestCard 626 . 4654)) (4687 26486 (NC.MakeLink 4697 . 
11065) (NC.LinkIconWhenCopiedFn 11067 . 19126) (NC.LinkIconWhenMovedFn 19128 . 26484)))))
STOP