(FILECREATED "18-Jan-88 17:14:03" {QV}<NOTECARDS>1.3KNEXT>NCCROSSFILELINKS.;6 29366  

      changes to:  (VARS NCCROSSFILELINKSCOMS)

      previous date: "30-Nov-87 15:55:37" {QV}<NOTECARDS>1.3KNEXT>NCCROSSFILELINKS.;5)


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

(PRETTYCOMPRINT NCCROSSFILELINKSCOMS)

(RPAQQ NCCROSSFILELINKSCOMS ((* * This file defines a card type called CrossFileLink that is a 
				  stand-in for really being able to link across notefiles.)
			       (* * A programmer can customize the icon which will appear on the 
				  right side of the link icon for cross-file links. The main hook is 
				  the property "AttachedBitMapFn" which should be placed on the card 
				  type's atom; which in this case is CrossFileLink. This function is 
				  called in the display code by 
				  NC.FetchCrossFileLinkIconAttachedBitMap when a cross-file link is 
				  encountered.)
			       (GLOBALVARS NC.CopyCrossFileLinksMode NC.CrossFileLinkIcon 
					   NC.MakeCrossFileLinkIconStandIn NC.NewCrossFileLinksMode 
					   NC.AttachedBitMapsHashArray NC.NoteFileAttachedBitMap 
					   NC.NoteFileAttachedBitMapMask)
			       (INITVARS (NC.NewCrossFileLinksMode (QUOTE ASK))
					 (NC.AttachedBitMapsHashArray))
			       (FNS NC.CrossFileLinkAttachedBitMapFn NC.FetchNoteFileAttachedBitmap)
			       (BITMAPS NC.CrossFileLinkIcon NC.NoteFileAttachedBitMap 
					NC.NoteFileAttachedBitMapMask)
			       (DECLARE: DONTEVAL@LOAD (VARS (NC.NewCrossFileLinksTwoWayFlg T)
							     (NC.CopyCrossFileLinksMode NIL)))
			       (FNS NC.AskCrossFileLinkMode NC.DeleteCrossFileLinkCard 
				    NC.FetchRemoteCrossFileLinkCard NC.CheckCrossFileLinkCardTitle 
				    NC.CheckCrossFileLinkType NC.MakeCrossFileLinkIconStandIn 
				    NC.ComputeCrossFileLinkMode 
				    NC.FetchCrossFileLinkIconAttachedBitMap)
			       (FNS NC.GetCrossFileLinkDestCard NC.CreateCrossFileLinkCard 
				    NC.CrossFileLinkCardP NC.OpenCrossFileLinkDestNoteFile)
			       (FNS NC.AddCrossFileLink NC.CrossFileLinkCopyFn NC.CrossFileLinkMakeFn 
				    NC.CrossFileLinkEditFn NC.CrossFileLinkGetFn 
				    NC.CrossFileLinkPutFn)
			       (RECORDS CrossFileLinkSubstance)
			       (DECLARE: DONTEVAL@LOAD (P (NC.AddCrossFileLink)
							  (PUTPROP (QUOTE CrossFileLink)
								   (QUOTE Don'tForceFilingFlg)
								   T)))
			       (FNS NCAddStub.CrossFileLink)))
(* * This file defines a card type called CrossFileLink that is a stand-in for really being 
able to link across notefiles.)

(* * A programmer can customize the icon which will appear on the right side of the link icon 
for cross-file links. The main hook is the property "AttachedBitMapFn" which should be placed 
on the card type's atom; which in this case is CrossFileLink. This function is called in the 
display code by NC.FetchCrossFileLinkIconAttachedBitMap when a cross-file link is encountered.)

(DECLARE: DOEVAL@COMPILE DONTCOPY

(GLOBALVARS NC.CopyCrossFileLinksMode NC.CrossFileLinkIcon NC.MakeCrossFileLinkIconStandIn 
	    NC.NewCrossFileLinksMode NC.AttachedBitMapsHashArray NC.NoteFileAttachedBitMap 
	    NC.NoteFileAttachedBitMapMask)
)

(RPAQ? NC.NewCrossFileLinksMode (QUOTE ASK))

(RPAQ? NC.AttachedBitMapsHashArray )
(DEFINEQ

(NC.CrossFileLinkAttachedBitMapFn
  [LAMBDA (Card CrossFileLinkDestCard ScaledHeightToMatch Scale)
                                                             (* pmi: " 5-Nov-87 14:09")

          (* * Compute the proper bitmap for the cross-file link card Card. The bitmaps are stored in a hash array using 
	  notefile objects for the keys.)


    (DECLARE (GLOBALVARS NC.DefaultLinkIconAttachedBitMapHeights NC.AttachedBitMapsHashArray))
    (LET (NoteFile BitMapSample BitMapList BitMap ScaledHeight)
         [SETQ NoteFile (NC.NoteFileFromNoteFileUID (fetch (CrossFileLinkSubstance 
								     CrossFileLinkDestNoteFileUID)
							   of (NCP.CardSubstance Card]

          (* * If we have not yet defined the hash array to hold the possible bitmaps, do so now.)


         (if (NOT (HARRAYP NC.AttachedBitMapsHashArray))
	     then (SETQ NC.AttachedBitMapsHashArray (HASHARRAY 100)))

          (* * If the bitmaps for this notefile have not already been defined, get a sample bitmap and create an array of 
	  bitmaps of different sizes.)


         (if [NOT (LISTP (SETQ BitMapList (GETHASH NoteFile NC.AttachedBitMapsHashArray]
	     then (SETQ BitMapSample (NC.FetchNoteFileAttachedBitmap NoteFile (
								      NC.CoerceToInterestedWindow
									     Card)))
		    (SETQ BitMapList (NC.MakeTypeIconBitMapSet BitMapSample 
							  NC.DefaultLinkIconAttachedBitMapHeights))
		    (PUTHASH NoteFile BitMapList NC.AttachedBitMapsHashArray))

          (* * Pick the proper size bitmap from the list as determined by ScaledHeightToMatch.)


         (OR ScaledHeightToMatch (SETQ ScaledHeightToMatch 0))
         (OR Scale (SETQ Scale 1))
         (for X on BitMapList by (CDDR X)
	    do (SETQ ScaledHeight (TIMES Scale (CAR X)))
		 (if (OR (NULL BitMap)
			     (LEQ ScaledHeight ScaledHeightToMatch))
		     then (SETQ BitMap (CADR X))
		   elseif (GREATERP ScaledHeight ScaledHeightToMatch)
		     then (RETURN)))
     BitMap])

(NC.FetchNoteFileAttachedBitmap
  [LAMBDA (NoteFile InterestedWindow)                        (* pmi: " 5-Nov-87 14:11")

          (* * One way to define the bitmaps for these cross-file link attached bitmaps -
	  let the user make up a shade.)


    (DECLARE (GLOBALVARS NC.NoteFileAttachedBitMap NC.NoteFileAttachedBitMapMask))
    (LET (NoteFileName BitMap BitMapShade)
         (SETQ NoteFileName (NCP.FileNameFromNoteFile NoteFile))
         (NCP.PrintMsg InterestedWindow T "Create a shade for notefile " NoteFileName)
         (SETQ BitMapShade (EDITSHADE))
         (NCP.ClearMsg InterestedWindow T)
         (SETQ BitMap (BITMAPCREATE (BITMAPWIDTH NC.NoteFileAttachedBitMap)
					(BITMAPHEIGHT NC.NoteFileAttachedBitMap)))
         (BITBLT NC.NoteFileAttachedBitMap NIL NIL BitMap NIL NIL NIL NIL (QUOTE INPUT)
		   (QUOTE PAINT))
         (BLTSHADE BitMapShade BitMap NIL NIL NIL NIL (QUOTE PAINT))
         (BITBLT NC.NoteFileAttachedBitMapMask NIL NIL BitMap NIL NIL NIL NIL (QUOTE INPUT)
		   (QUOTE ERASE))
     BitMap])
)

(RPAQ NC.CrossFileLinkIcon (READBITMAP))
(21 18
"OOOOOH@@"
"H@@@@H@@"
"H@@@@H@@"
"H@CH@H@@"
"H@AL@H@@"
"H@@N@H@@"
"H@@G@H@@"
"IOOOHH@@"
"IOOOLH@@"
"IOOOHH@@"
"H@@G@H@@"
"H@@N@H@@"
"H@AL@H@@"
"H@CH@H@@"
"H@@@@H@@"
"H@@@@H@@"
"H@@@@H@@"
"OOOOOH@@")

(RPAQ NC.NoteFileAttachedBitMap (READBITMAP))
(21 18
"OOO@@@@@"
"@@AH@@@@"
"@@@L@@@@"
"@@@F@@@@"
"@@@C@@@@"
"@@@AH@@@"
"@@@@L@@@"
"@@@@F@@@"
"@@@@C@@@"
"@@@@C@@@"
"@@@@F@@@"
"@@@@L@@@"
"@@@AH@@@"
"@@@C@@@@"
"@@@F@@@@"
"@@@L@@@@"
"@@AH@@@@"
"OOO@@@@@")

(RPAQ NC.NoteFileAttachedBitMapMask (READBITMAP))
(21 18
"@@@OOH@@"
"@@@GOH@@"
"@@@COH@@"
"@@@AOH@@"
"@@@@OH@@"
"@@@@GH@@"
"@@@@CH@@"
"@@@@AH@@"
"@@@@@H@@"
"@@@@@H@@"
"@@@@AH@@"
"@@@@CH@@"
"@@@@GH@@"
"@@@@OH@@"
"@@@AOH@@"
"@@@COH@@"
"@@@GOH@@"
"@@@OOH@@")
(DECLARE: DONTEVAL@LOAD 

(RPAQQ NC.NewCrossFileLinksTwoWayFlg T)

(RPAQQ NC.CopyCrossFileLinksMode NIL)
)
(DEFINEQ

(NC.AskCrossFileLinkMode
  [LAMBDA (DestCard InterestedWindow)                        (* rht: " 4-Jun-87 14:58")

          (* * Ask the user whether to make the link be twoway or oneway. Return T if user says two-way.
	  If dest notefile is open read-only, then only choice is one-way so don't ask.)


    (LET* ((NoteFile (fetch (Card NoteFile) of DestCard))
	   (FullFileName (fetch (NoteFile FullFileName) of NoteFile)))
          (if (NC.ReadOnlyNoteFileP NoteFile)
	      then NIL
	    else (NC.AskYesOrNo (CONCAT "Okay to make cross-file link to '" (NC.RetrieveTitle
						DestCard)
					      "' in '"
					      (FILENAMEFIELD FullFileName (QUOTE NAME))
					      ";"
					      (FILENAMEFIELD FullFileName (QUOTE VERSION))
					      "' be TWOWAY?"
					      (CHARACTER 13)
					      
				  "(otherwise leaves no record of link in destination notefile) ")
				    " -- " "Yes" T InterestedWindow])

(NC.DeleteCrossFileLinkCard
  [LAMBDA (CrossFileLinkCard)                                (* rht: "27-May-87 21:54")

          (* * Delete the crossfile link card. If it's a twoway crossfile link, and its "twin" is in an open notefile, then 
	  delete the cross file link over there.)


    (LET ((DestCard (NC.FetchRemoteCrossFileLinkCard CrossFileLinkCard)))
         (if DestCard
	     then (NC.DeleteNoteCardInternal DestCard T))
         (NC.DeleteNoteCardInternal CrossFileLinkCard T])

(NC.FetchRemoteCrossFileLinkCard
  [LAMBDA (CrossFileLinkCard)                                (* rht: "27-May-87 21:54")

          (* * Return the remote "twin" of CrossFileLinkCard if its notefile is open.)


    (LET ((CrossFileLinkSubstance (NCP.CardSubstance CrossFileLinkCard))
	  DestCard RemoteCrossFileLinkCardUID NoteFileUID NoteFile)
         (if [AND (fetch (CrossFileLinkSubstance CrossFileLinkTwoWayFlg) of 
									   CrossFileLinkSubstance)
		      (SETQ RemoteCrossFileLinkCardUID (fetch (CrossFileLinkSubstance 
								       RemoteCrossFileLinkCardUID)
							    of CrossFileLinkSubstance))
		      (type? UID (SETQ NoteFileUID (fetch (CrossFileLinkSubstance 
								     CrossFileLinkDestNoteFileUID)
							  of CrossFileLinkSubstance)))
		      (NCP.OpenNoteFileP (SETQ NoteFile (NC.NoteFileFromNoteFileUID NoteFileUID)
					     ))
		      (NC.ValidCardP (SETQ DestCard (NC.CardFromUID RemoteCrossFileLinkCardUID 
									  NoteFile]
	     then DestCard
	   else NIL])

(NC.CheckCrossFileLinkCardTitle
  [LAMBDA (CrossFileLinkCard DestinationCard)                (* rht: "27-May-87 21:47")

          (* * If titles don't agree, change crossfilelink card title to match.)


    (LET ((DestinationCardTitle (NC.RetrieveTitle DestinationCard)))
         (if (NOT (STREQUAL DestinationCardTitle (NC.RetrieveTitle CrossFileLinkCard)))
	     then (NC.AssignTitle CrossFileLinkCard NIL DestinationCardTitle])

(NC.CheckCrossFileLinkType
  [LAMBDA (RemoteCrossFileLinkCard LocalCrossFileLinkCard Link)
                                                             (* rht: "27-May-87 22:33")

          (* * If link types don't agree, change remote crossfilelink type to match.)


    (LET ((RemoteDestCard (NC.GetCrossFileLinkDestCard LocalCrossFileLinkCard NIL T))
	  (LinkLabel (fetch (Link Label) of Link))
	  RemoteLink NoteFile)
         (if RemoteDestCard
	     then [SETQ RemoteLink (OR (for FromLink in (NC.RetrieveFromLinks 
									  RemoteCrossFileLinkCard)
						when (NC.SameCardP (fetch (Link SourceCard)
									  of FromLink)
								       RemoteDestCard)
						do (RETURN FromLink))
					     (for ToLink in (NC.RetrieveToLinks 
									  RemoteCrossFileLinkCard)
						when (NC.SameCardP (fetch (Link DestinationCard)
									  of ToLink)
								       RemoteDestCard)
						do (RETURN ToLink]
		    (if (NOT (EQ (fetch (Link Label) of RemoteLink)
				       LinkLabel))
			then (if [NOT (NCP.ValidLinkTypeP LinkLabel (SETQ NoteFile
								    (fetch (Card NoteFile)
								       of RemoteCrossFileLinkCard]
				   then (NCP.CreateLinkType LinkLabel NoteFile))
			       (NC.RelabelLink RemoteLink NIL LinkLabel])

(NC.MakeCrossFileLinkIconStandIn
  [LAMBDA (CrossFileLinkCard)                                (* rht: "27-May-87 23:39")

          (* * Return an imageobj to act as a standin for a cross file link.)


    (DECLARE (GLOBALVARS NC.ExternalPutLinkIconImageFns))
    (IMAGEOBJCREATE (CONCAT "[[ Cross-file link to '" (NC.RetrieveTitle CrossFileLinkCard)
				"' ]]")
		      NC.ExternalPutLinkIconImageFns])

(NC.ComputeCrossFileLinkMode
  [LAMBDA (RemoteCard CrossFileLinkModePropList InterestedWindow)
                                                             (* rht: " 6-Jun-87 16:19")

          (* * If we've already made cross file links to RemoteCard's notefile, then it'll be registered on 
	  CrossFileLinkModePropList. Otherwise, consult global var, possibly ask user, and register her answer on 
	  CrossFileLinkModePropList.)



          (* * rht 6/6/87: Changed so that check of globalvar happens before check of CrossFileLinkModePropList.)


    (DECLARE (GLOBALVARS NC.NewCrossFileLinksMode))
    (LET ((NoteFile (fetch (Card NoteFile) of RemoteCard))
	  Mode)
         (COND
	   ((FMEMB NC.NewCrossFileLinksMode (QUOTE (TWOWAY ONEWAY)))
	     NC.NewCrossFileLinksMode)
	   ((FMEMB NoteFile CrossFileLinkModePropList)
	     (LISTGET CrossFileLinkModePropList NoteFile))
	   (T (SETQ Mode (if (NC.AskCrossFileLinkMode RemoteCard InterestedWindow)
			       then (QUOTE TWOWAY)
			     else (QUOTE ONEWAY)))
	      (LISTPUT CrossFileLinkModePropList NoteFile Mode)
	      Mode])

(NC.FetchCrossFileLinkIconAttachedBitMap
  [LAMBDA (Card CrossFileLinkDestCard ScaledHeightToMatch Scale)
                                                             (* pmi: " 4-Nov-87 19:14")

          (* * Hook for user to calculate the bitmap to be displayed on the right side of a link icon if it is a cross-file 
	  link and it's attached bitmap is being displayed.)


    (LET ((AttachedBitMapFn (GETPROP (QUOTE CrossFileLink)
				       (QUOTE AttachedBitMapFn)))
	  BitMap)

          (* * If a special bitmap has been defined, return it. Otherwise, just return the standard cross-file link bitmap.)


         (if (AND AttachedBitMapFn (SETQ BitMap (APPLY* AttachedBitMapFn Card 
								CrossFileLinkDestCard 
								ScaledHeightToMatch Scale)))
	     then BitMap
	   else (NC.FetchLinkIconAttachedBitMap Card ScaledHeightToMatch Scale])
)
(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])

(NC.CreateCrossFileLinkCard
  [LAMBDA (SourceCard DestCard TwoWayFlg)                    (* rht: " 9-Dec-86 14:50")

          (* * Create a cross file link card in SourceCard's notefile.)



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



          (* * rht 12/9/86: No longer records fact that card was "just created.")


    (LET ((DestNoteFile (fetch (Card NoteFile) of DestCard))
	  CrossFileLinkCard)
         (SETQ CrossFileLinkCard (NC.MakeNoteCard (QUOTE CrossFileLink)
						      (fetch (Card NoteFile) of SourceCard)
						      (NC.FetchTitle DestCard)
						      T
						      (create CrossFileLinkSubstance
								CrossFileLinkDestCardUID ←
								(fetch (Card UID) of DestCard)
								CrossFileLinkDestNoteFileUID ←
								(fetch (NoteFile UID) of 
										     DestNoteFile)
								CrossFileLinkDestFileHint ←
								(PACKFILENAME (QUOTE VERSION)
										NIL
										(QUOTE BODY)
										(fetch
										  (NoteFile 
										     FullFileName)
										   of DestNoteFile))
								CrossFileLinkTwoWayFlg ← TwoWayFlg)))
                                                             (* Indicate that card was just created.)
     CrossFileLinkCard])

(NC.CrossFileLinkCardP
  (LAMBDA (Card)                                             (* rht: " 6-Oct-86 10:49")

          (* * Return non-nil if card is a crossfilelink card.)


    (EQ (NC.FetchType Card)
	  (QUOTE CrossFileLink))))

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

(NC.AddCrossFileLink
  [LAMBDA NIL                                                (* rht: "20-Nov-86 00:04")

          (* * rht 11/19/86: Added LinkIconAttachedBitMap field.)


    (DECLARE (GLOBALVARS NC.CrossFileLinkIcon))
    (NC.AddCardType (QUOTE CrossFileLink)
		      (QUOTE NoteCard)
		      [BQUOTE ((MakeFn , (FUNCTION NC.CrossFileLinkMakeFn))
				 (EditFn , (FUNCTION NC.CrossFileLinkEditFn))
				 (GetFn , (FUNCTION NC.CrossFileLinkGetFn))
				 (PutFn , (FUNCTION NC.CrossFileLinkPutFn))
				 (CopyFn , (FUNCTION NC.CrossFileLinkCopyFn))
				 (MarkDirtyFn , (FUNCTION NILL))
				 (DirtyPFn , (FUNCTION NILL))
				 (QuitFn , (FUNCTION NILL))
				 (DeleteLinksFn , (FUNCTION NILL))
				 (InsertLinkFn , (FUNCTION NILL))
				 (CollectLinksFn , (FUNCTION NILL))
				 (UpdateLinkIconsFn , (FUNCTION NILL))
				 (TranslateWindowPositionFn , (FUNCTION NILL]
		      (BQUOTE ((LinkAnchorModesSupported NIL)
				 (LinkDisplayMode , (NC.InsureLinkDisplayMode (QUOTE Title)))
				 (LinkIconAttachedBitMap , NC.CrossFileLinkIcon])

(NC.CrossFileLinkCopyFn
  (LAMBDA (Card FromStream ToStream Length)                  (* rht: " 3-Oct-86 20:20")

          (* * Copy a CrossFileLink substance from FromStream to ToStream.)


    (LET* ((FromStartPtr (GETFILEPTR FromStream))
	   (FromEndPtr (PLUS Length FromStartPtr)))
          (COPYBYTES FromStream ToStream FromStartPtr FromEndPtr))
    T))

(NC.CrossFileLinkMakeFn
  (LAMBDA (Card Title NoDisplayFlg CrossFileLinkSubstance)   (* rht: " 3-Oct-86 20:42")

          (* * Make a CrossFileLink substance.)


    (NC.SetSubstance Card CrossFileLinkSubstance)
    Card))

(NC.CrossFileLinkEditFn
  [LAMBDA (Card Substance ReadOnly RegionOrPosition TypeSpecificArgs)
                                                             (* Randy.Gobbel " 4-Nov-87 14:12")

          (* * Given a CrossFileLink Substance, try to find the corresponding destination card in the destination notefile 
	  and bring it up.)



          (* * rht 11/13/86: Now updates title of crossfile link card to be the same as destination card if necessary.)



          (* * rht 5/27/87: Now calls NC.CheckCrossFileLinkCardTitle.)



          (* * rg 11/4/87 added ReadOnly)


    (LET ((DestinationCard (NC.GetCrossFileLinkDestCard Card))
	  DestinationCardTitle)
         (if DestinationCard
	     then (NC.CheckCrossFileLinkCardTitle Card DestinationCard)
		    (NC.EditNoteCard DestinationCard (OR ReadOnly (fetch (NoteFile ReadOnlyFlg)
									 of (fetch (Card NoteFile)
										 of Card)))
				       RegionOrPosition TypeSpecificArgs])

(NC.CrossFileLinkGetFn
  [LAMBDA (Card Length Stream VersionNum)                    (* rht: "27-May-87 15:06")

          (* * Get the crossfilelink substance from the disk)



          (* * rht 11/1/86: Now uses our readtable when reading.)



          (* * rht 5/27/87: Now reads in new format of CrossFileLinkSubstance record with two new fields.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (if (LEQ VersionNum 0)
	then (create CrossFileLinkSubstance
			 CrossFileLinkDestCardUID ← (NC.ReadUID Stream)
			 CrossFileLinkDestNoteFileUID ← (NC.ReadUID Stream)
			 CrossFileLinkDestFileHint ← (READ Stream NC.OrigReadTable))
      else (create CrossFileLinkSubstance
		       CrossFileLinkDestCardUID ← (NC.ReadUID Stream)
		       CrossFileLinkDestNoteFileUID ← (NC.ReadUID Stream)
		       RemoteCrossFileLinkCardUID ← (NC.ReadUID Stream)
		       CrossFileLinkDestFileHint ← (READ Stream NC.OrigReadTable)
		       CrossFileLinkTwoWayFlg ← (READ Stream NC.OrigReadTable])

(NC.CrossFileLinkPutFn
  [LAMBDA (Card Stream)                                      (* rht: "27-May-87 15:07")

          (* * Put crossfilelink substance)



          (* * rht 11/1/86: Now uses our readtable when printing.)



          (* * rht 5/27/87: Changed to write down new fields RemoteCrossFileLinkCardUID and CrossFileLinkTwoWayFlg of 
	  CrossFileLinkSubstance record.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (LET ((Substance (NC.FetchSubstance Card)))
         (NC.WriteUID Stream (fetch (CrossFileLinkSubstance CrossFileLinkDestCardUID)
				  of Substance))
         (NC.WriteUID Stream (fetch (CrossFileLinkSubstance CrossFileLinkDestNoteFileUID)
				  of Substance))
         (NC.WriteUID Stream (fetch (CrossFileLinkSubstance RemoteCrossFileLinkCardUID)
				  of Substance))
         (PRINT (fetch (CrossFileLinkSubstance CrossFileLinkDestFileHint) of Substance)
		  Stream NC.OrigReadTable)
         (PRINT (fetch (CrossFileLinkSubstance CrossFileLinkTwoWayFlg) of Substance)
		  Stream NC.OrigReadTable))
    1])
)
[DECLARE: EVAL@COMPILE 

(DATATYPE CrossFileLinkSubstance (CrossFileLinkDestCardUID CrossFileLinkDestNoteFileUID 
							     CrossFileLinkDestFileHint (
							       CrossFileLinkTwoWayFlg FLAG)
							     RemoteCrossFileLinkCardUID))
]
(/DECLAREDATATYPE (QUOTE CrossFileLinkSubstance)
		  (QUOTE (POINTER POINTER POINTER FLAG POINTER))
		  (QUOTE ((CrossFileLinkSubstance 0 POINTER)
			  (CrossFileLinkSubstance 2 POINTER)
			  (CrossFileLinkSubstance 4 POINTER)
			  (CrossFileLinkSubstance 4 (FLAGBITS . 0))
			  (CrossFileLinkSubstance 6 POINTER)))
		  (QUOTE 8))
(DECLARE: DONTEVAL@LOAD 
(NC.AddCrossFileLink)
(PUTPROP (QUOTE CrossFileLink)
	 (QUOTE Don'tForceFilingFlg)
	 T)
)
(DEFINEQ

(NCAddStub.CrossFileLink
  (LAMBDA NIL                                                (* rht: " 4-Oct-86 00:36")

          (* * kirk 18Jun86 Add the CrossFileLink card stub)


    (NC.AddCardTypeStub (QUOTE CrossFileLink)
			  (QUOTE NoteCard)
			  (QUOTE NCCROSSFILELINKS))))
)
(PUTPROPS NCCROSSFILELINKS COPYRIGHT ("Xerox Corporation" 1986 1987 1988))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (3270 6587 (NC.CrossFileLinkAttachedBitMapFn 3280 . 5453) (
NC.FetchNoteFileAttachedBitmap 5455 . 6585)) (7461 14487 (NC.AskCrossFileLinkMode 7471 . 8461) (
NC.DeleteCrossFileLinkCard 8463 . 8990) (NC.FetchRemoteCrossFileLinkCard 8992 . 10080) (
NC.CheckCrossFileLinkCardTitle 10082 . 10554) (NC.CheckCrossFileLinkType 10556 . 11956) (
NC.MakeCrossFileLinkIconStandIn 11958 . 12393) (NC.ComputeCrossFileLinkMode 12395 . 13573) (
NC.FetchCrossFileLinkIconAttachedBitMap 13575 . 14485)) (14488 23263 (NC.GetCrossFileLinkDestCard 
14498 . 18952) (NC.CreateCrossFileLinkCard 18954 . 20277) (NC.CrossFileLinkCardP 20279 . 20536) (
NC.OpenCrossFileLinkDestNoteFile 20538 . 23261)) (23264 28261 (NC.AddCrossFileLink 23274 . 24405) (
NC.CrossFileLinkCopyFn 24407 . 24791) (NC.CrossFileLinkMakeFn 24793 . 25032) (NC.CrossFileLinkEditFn 
25034 . 26050) (NC.CrossFileLinkGetFn 26052 . 27118) (NC.CrossFileLinkPutFn 27120 . 28259)) (28952 
29269 (NCAddStub.CrossFileLink 28962 . 29267)))))
STOP