(FILECREATED "14-May-85 13:07:14" {PHYLUM}<NOTECARDS>RELEASE1.2>FGHPATCH011.;1 5651   

      changes to:  (VARS FGHPATCH011COMS)
		   (FNS NC.InsertLinkAlphabetically))


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

(PRETTYCOMPRINT FGHPATCH011COMS)

(RPAQQ FGHPATCH011COMS ((FNS NC.MakeAContentsHook NC.InsertLinkAlphabetically)))
(DEFINEQ

(NC.MakeAContentsHook
  (LAMBDA (ContentsID DestinationID SubOrSuperFlg DatabaseStream)
                                                             (* fgh: "14-May-85 12:43")

          (* Make a link from a contents card to another card as specified by DestinationID. If card is a regular card, insert
	  link at end of contents card. If card is a supercontents of contents card then insert just before the subcontents 
	  marker (i.e., at end of super contents list). If card is a subcontents card then insert just before note cards 
	  marker (i.e., at end of subcontents list))


    (PROG ((FilingScheme (LISTGET (NC.RetrievePropList ContentsID DatabaseStream)
				  (QUOTE FilingScheme))))
          (RETURN (COND
		    ((EQ FilingScheme (QUOTE Alphabetic))
		      (NC.InsertLinkAlphabetically ContentsID DestinationID (COND
						     ((EQ SubOrSuperFlg (QUOTE Sub))
						       NC.SubBoxLinkLabel)
						     (T NC.FiledCardLinkLabel))
						   NIL DatabaseStream NIL))
		    ((EQ SubOrSuperFlg (QUOTE Sub))
		      (NC.InsertLinkBeforeMarker ContentsID DestinationID NC.SubBoxLinkLabel NIL 2 
						 DatabaseStream))
		    (T (NC.InsertLinkBeforeMarker ContentsID DestinationID NC.FiledCardLinkLabel NIL 
						  NIL DatabaseStream)))))))

(NC.InsertLinkAlphabetically
  (LAMBDA (SourceID DestinationID LinkLabel DisplayMode DatabaseStream NoSpacerFlg)
                                                             (* fgh: "14-May-85 12:55")
                                                             (* Insert a link to DestinationID in SourceID.
							     Place to insert is dertermined alphabetically.)
    (PROG (Objects TextStream TextObject SEL InsertCharPtr (Spacer (CONCAT (CHARACTER 13)))
		   Link
		   (DestinationTitle (NC.RetrieveTitle DestinationID DatabaseStream)))
          (COND
	    ((NC.ActiveCardP SourceID)
	      (SETQ TextStream (NC.FetchSubstance SourceID))
	      (SETQ TextObject (TEXTOBJ TextStream))
	      (COND
		((SETQ Objects (TEDIT.LIST.OF.OBJECTS TextObject (FUNCTION NC.LinkIconImageObjP)))
		  (for ObjectPair in Objects when (ALPHORDER DestinationTitle
							     (NC.RetrieveTitle
							       (fetch (NOTECARDLINK DESTINATIONID)
								  of (NC.FetchLinkFromLinkIcon
								       (CAR ObjectPair)))
							       DatabaseStream))
		     do (TEDIT.SETSEL TextStream (SUB1 (CADR ObjectPair))
				      0
				      (QUOTE LEFT))
			(RETURN NIL)
		     finally (TEDIT.SETSEL TextStream (GETEOFPTR TextStream)
					   0
					   (QUOTE RIGHT)))))
	      (SETQ SEL (fetch (TEXTOBJ SEL) of TextObject))
	      (SETQ Link (NC.InsertLinkInText TextStream LinkLabel DestinationID SourceID DisplayMode)
		)
	      (COND
		((NULL NoSpacerFlg)
		  (TEDIT.SETSEL TextStream (SELECTQ (fetch (SELECTION POINT) of SEL)
						    (LEFT (SUB1 (fetch (SELECTION CH#) of SEL)))
						    (RIGHT (IMIN (ADD1 (fetch (TEXTOBJ TEXTLEN)
									  of TextObject))
								 (ADD1 (fetch (SELECTION CHLIM)
									  of SEL))))
						    NIL)
				0
				(QUOTE RIGHT))
		  (TEDIT.INSERT TextStream Spacer))))
	    (T (WITH.MONITOR (NC.FetchMonitor DatabaseStream)
			     (COND
			       ((NC.IDP (NC.GetNoteCard SourceID DatabaseStream))
				 (SETQ TextStream (NC.FetchSubstance SourceID))
				 (SETQ TextObject (TEXTOBJ TextStream))
				 (COND
				   ((SETQ Objects (TEDIT.LIST.OF.OBJECTS TextObject
									 (FUNCTION 
									   NC.LinkIconImageObjP)))
				     (FOR ObjectPair in Objects
					WHEN (ALPHORDER DestinationTitle
							(NC.RetrieveTitle (fetch (NOTECARDLINK 
										    DESTINATIONID)
									     of (
NC.FetchLinkFromLinkIcon (CAR ObjectPair)))
									  DatabaseStream))
					DO (TEDIT.SETSEL TextStream (SUB1 (CADR ObjectPair))
							 0
							 (QUOTE LEFT))
					   (RETURN NIL)
					FINALLY (TEDIT.SETSEL TextStream (GETEOFPTR TextStream)
							      0
							      (QUOTE RIGHT)))))
				 (SETQ SEL (fetch (TEXTOBJ SEL) of TextObject))
				 (SETQ Link (NC.InsertLinkInText TextStream LinkLabel DestinationID 
								 SourceID DisplayMode))
				 (COND
				   ((NULL NoSpacerFlg)
				     (TEDIT.SETSEL TextStream
						   (SELECTQ (fetch (SELECTION POINT) of SEL)
							    (LEFT (SUB1 (fetch (SELECTION CH#)
									   of SEL)))
							    (RIGHT (IMIN (ADD1 (fetch (TEXTOBJ 
											  TEXTLEN)
										  of TextObject))
									 (ADD1 (fetch (SELECTION
											CHLIM)
										  of SEL))))
							    NIL)
						   0
						   (QUOTE RIGHT))
				     (TEDIT.INSERT TextStream Spacer)))
				 (NC.PutNoteCard SourceID DatabaseStream)
				 (NC.PutLinks SourceID DatabaseStream)
				 (NC.DeactivateCard SourceID))))))
          (RETURN Link))))
)
(PUTPROPS FGHPATCH011 COPYRIGHT ("Xerox Corporation" 1985))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (364 5569 (NC.MakeAContentsHook 374 . 1712) (NC.InsertLinkAlphabetically 1714 . 5567))))
)
STOP