(FILECREATED "21-Nov-86 00:35:44" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH155.;3 74794  

      changes to:  (FNS NCP.ReportWarning NCP.ReportError NCP.CloseNoteFiles NCP.CreateCardType 
			NCP.CreateCardTypeStub)
		   (VARS RHTPATCH155COMS)

      previous date: "16-Nov-86 22:48:18" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH155.;1)


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

(PRETTYCOMPRINT RHTPATCH155COMS)

(RPAQQ RHTPATCH155COMS ((* * Change to allow break in calls to NCP.ReportError.)
	(* * New stuff for NCPROGINT)
	(GLOBALVARS NCP.ErrorBrkWhenFlg)
	(INITVARS (NCP.ErrorBrkWhenFlg NIL))
	(* * Changed in NCPROGINT)
	(FNS NCP.ReportError NCP.ReportWarning)
	(FNS NCP.CreateNoteFile NCP.CloseNoteFiles NCP.CheckpointNoteFiles NCP.AbortNoteFiles 
	     NCP.RepairNoteFile NCP.FileNameFromNoteFile NCP.ChangeCardTypeFields NCP.CardTypeSuper 
	     NCP.CardTypeLinkDisplayMode NCP.CardTypeFn NCP.CardTypeVar NCP.CardTypeDisplayedInMenu 
	     NCP.IsSubTypeOfP NCP.TextBasedP NCP.SketchBasedP NCP.GraphBasedP NCP.CreateCard 
	     NCP.CreateBrowserCard NCP.MakeDocument NCP.MakeLinkIndex NCP.OpenCard NCP.CloseCards 
	     NCP.DisplayCard NCP.UndisplayCards NCP.CacheCards NCP.UncacheCards NCP.CardTitle 
	     NCP.FileCards NCP.UnfileCards NCP.CardParents NCP.FileBoxChildren NCP.GetLinks 
	     NCP.CardProp NCP.CardAddProp NCP.CardDelProp NCP.CardSubstance NCP.CardRegion 
	     NCP.CardAddText NCP.ChangeLoc NCP.DeleteCards NCP.SameCardP NCP.CreateLink 
	     NCP.LocalGlobalLink NCP.GlobalGlobalLink NCP.GlobalLocalLink NCP.LocalLocalLink 
	     NCP.LinkDesc NCP.LinkDisplayMode NCP.LinkType NCP.LinkSource NCP.LinkDestination 
	     NCP.DeleteLinks NCP.SameLinkP NCP.CreateLinkType NCP.DeleteLinkType NCP.RenameLinkType 
	     NCP.CardDates NCP.DocumentParameters NCP.NoteCardsParameters NCP.RegisterCardByName 
	     NCP.LookupCardByName NCP.UnregisterName NCP.CardUserDataProp NCP.NoteFileProp)
	(FNS NCP.CreateCardType NCP.CreateCardTypeStub)
	(DECLARE: DONTEVAL@LOAD DOEVAL@COMPILE DONTCOPY COMPILERVARS
		  (ADDVARS (NLAMA)
			   (NLAML)
			   (LAMA NCP.NoteFileProp NCP.CardUserDataProp NCP.LinkType 
				 NCP.LinkDisplayMode NCP.CardSubstance NCP.CardProp NCP.CardTitle 
				 NCP.CardTypeDisplayedInMenu)))))
(* * Change to allow break in calls to NCP.ReportError.)

(* * New stuff for NCPROGINT)

(DECLARE: DOEVAL@COMPILE DONTCOPY

(GLOBALVARS NCP.ErrorBrkWhenFlg)
)

(RPAQ? NCP.ErrorBrkWhenFlg NIL)
(* * Changed in NCPROGINT)

(DEFINEQ

(NCP.ReportError
  (LAMBDA (FunctionName Msg)                                 (* rht: "16-Nov-86 22:58")

          (* * Print out the various elements of Args to the terminal.)



          (* * rht 11/16/86: Now takes different args and does optional break. Consults NCP.ErrorBrkWhenFlg.)


    (DECLARE (GLOBALVARS NCP.ErrorBrkWhenFlg))
    (if (EQ NCP.ErrorBrkWhenFlg (QUOTE NEVER))
	then (PRIN1 "*** NC-PI error: " T)
	       (PRIN1 Msg T)
	       (TERPRI T)
      else (APPLY* (QUOTE BREAK1)
		       T T FunctionName NIL NIL (LIST Msg)))))

(NCP.ReportWarning
  (LAMBDA (FunctionName Msg)                                 (* rht: "21-Nov-86 00:34")

          (* * Print out the various elements of Args to the terminal.)



          (* * rht 11/16/86: Now takes different args and does optional break. Consults NCP.ErrorBrkWhenFlg.)


    (DECLARE (GLOBALVARS NCP.ErrorBrkWhenFlg))
    (if (NEQ NCP.ErrorBrkWhenFlg (QUOTE ALWAYS))
	then (PRIN1 "*** NC-PI warning: " T)
	       (PRIN1 Msg T)
	       (TERPRI T)
      else (APPLY* (QUOTE BREAK1)
		       T T FunctionName NIL NIL (LIST Msg)))))
)
(DEFINEQ

(NCP.CreateNoteFile
  (LAMBDA (FileName QuietFlg)                                (* rht: "16-Nov-86 21:57")

          (* * Prog intface function for creating a notefile.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (LET ((FileNameWithExt (NC.DatabaseFileName NIL NIL NIL NIL FileName)))
         (if (INFILEP FileNameWithExt)
	     then (NCP.ReportError "NCP.CreateNoteFile" (CONCAT "NCP.CreateNoteFile" 
								      "Filename "
								      FileNameWithExt 
								      " already exists."))
		    NIL
	   else (NC.CreateDatabaseFile FileNameWithExt NIL NIL NIL NIL NIL NIL QuietFlg)
		  FileNameWithExt))))

(NCP.CloseNoteFiles
  (LAMBDA (NoteFilesOrT QuietFlg)                            (* rht: "16-Nov-86 22:53")

          (* * Prog's intface function for closing a notefile.)



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



          (* * rht 7/7/86: Now takes list of notefiles. If arg is T, then close all open notefiles.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)



          (* * 11/16/86: Now calls NC.CloseNoteFile instead of NC.CloseDatabaseFile.)


    (for NoteFile in (if (EQ NoteFilesOrT T)
			     then (NCP.ListOfOpenNoteFiles)
			   else (MKLIST NoteFilesOrT))
       do (if (NOT (NCP.OpenNoteFileP NoteFile))
		then (NCP.ReportError "NCP.CloseNoteFiles" (CONCAT "Argument " NoteFile 
							     " is not a currently open notefile."))
		       NIL
	      else (NC.CloseNoteFile NoteFile NIL NIL QuietFlg)))))

(NCP.CheckpointNoteFiles
  (LAMBDA (NoteFilesOrT QuietFlg)                            (* rht: "16-Nov-86 21:58")

          (* * Checkpoint the given notefiles. If T then checkpoint all open notefiles.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (for NoteFile in (if (EQ NoteFilesOrT T)
			     then (NCP.ListOfOpenNoteFiles)
			   else (MKLIST NoteFilesOrT))
       do (if (NOT (NCP.OpenNoteFileP NoteFile))
		then (NCP.ReportError "NCP.CheckpointNoteFiles" (CONCAT "Argument " NoteFile 
							     " is not a currently open notefile."))
		       NIL
	      else (NC.CheckpointDatabase NoteFile QuietFlg)))))

(NCP.AbortNoteFiles
  (LAMBDA (NoteFilesOrT Don'tConfirmFlg QuietFlg)            (* rht: "16-Nov-86 21:59")

          (* * Abort the given notefiles. If T then abort all open notefiles.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (for NoteFile in (if (EQ NoteFilesOrT T)
			     then (NCP.ListOfOpenNoteFiles)
			   else (MKLIST NoteFilesOrT))
       do (if (NOT (NCP.OpenNoteFileP NoteFile))
		then (NCP.ReportError "NCP.AbortNotefiles" (CONCAT "Argument " NoteFile 
							     " is not a currently open notefile."))
		       NIL
	      else (NC.AbortSession NoteFile NIL Don'tConfirmFlg QuietFlg)))))

(NCP.RepairNoteFile
  (LAMBDA (NoteFileOrFileName ReadSubstancesFlg)             (* rht: "16-Nov-86 22:27")

          (* * Prog's intface function for running inspect&repair on a notefile.)



          (* * rht 7/17/86: Now takes and passes ReadSubstancesFlg and calls NC.InspectAndRepairNoteFile instead of 
	  NC.ScavengerPhase1.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (if (NCP.OpenNoteFileP NoteFileOrFileName)
	then (NCP.ReportError "NCP.RepairNoteFile" (CONCAT 
							"Can't inspect&repair an open notefile: "
								 NoteFileOrFileName))
      else (NC.InspectAndRepairNoteFile NoteFileOrFileName ReadSubstancesFlg))))

(NCP.FileNameFromNoteFile
  (LAMBDA (NoteFile)                                         (* rht: "16-Nov-86 22:27")

          (* * Grab filename off of this notefile object.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (if (NOT (type? NoteFile NoteFile))
	then (NCP.ReportError "NCP.FileNameFromNoteFile" (CONCAT 
					    "Arg to NCP.FileNameFromNoteFile is not a notefile: "
								       NoteFile))
      else (fetch (NoteFile FullFileName) of NoteFile))))

(NCP.ChangeCardTypeFields
  (LAMBDA (TypeName FnsAssocList VarsAssocList)              (* rht: "16-Nov-86 22:28")

          (* * Change the given fields of TypeName.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (if (NCP.CardTypeP TypeName)
	then (NC.RecomputeCardType TypeName FnsAssocList VarsAssocList)
      else (NCP.ReportError "NCP.ChangeCardTypeFields" (CONCAT "Undefined card type: " TypeName)
				))))

(NCP.CardTypeSuper
  (LAMBDA (Type)                                             (* rht: "16-Nov-86 21:59")

          (* * Return the super type for this type.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (if (NCP.CardTypeP Type)
	then (NC.GetCardTypeField SuperType Type)
      else (NCP.ReportError "NCP.CardTypeSuper" (CONCAT Type " is not a loaded NoteCard type."))
	     NIL)))

(NCP.CardTypeLinkDisplayMode
  (LAMBDA (Type)                                             (* rht: "16-Nov-86 22:00")

          (* * Return the link display mode for this type.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (if (NCP.CardTypeP Type)
	then (NC.GetCardTypeField LinkDisplayMode Type)
      else (NCP.ReportError "NCP.CardTypeLinkDisplayMode" (CONCAT Type 
								" is not a loaded NoteCard type."))
	     NIL)))

(NCP.CardTypeFn
  (LAMBDA (TypeName Fn)                                      (* rht: "16-Nov-86 22:29")

          (* * Return the function stored as the Fn for TypeName's record.)



          (* * rht 7/7/86: Replaced NIL DEC in RECORDACCESS call with RECLOOK)



          (* * rht 8/25/86: Changed RECORDACCESS to slightly less scuzzy call to NC.GetCardTypeField, the advantage is that 
	  the latter will force autoload if necessary.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (if (NCP.CardTypeP TypeName)
	then (if (NCP.ValidCardTypeFn Fn)
		   then (EVAL (BQUOTE (NC.GetCardTypeField , Fn TypeName)))
		 else (NCP.ReportError "NCP.CardTypeFn" (CONCAT Fn 
						       " is not a kind of Fn for NoteCard types.")))
      else (NCP.ReportError "NCP.CardTypeFn" (CONCAT TypeName " is not a loaded NoteCard type.")
				)
	     NIL)))

(NCP.CardTypeVar
  (LAMBDA (TypeName Var)                                     (* rht: "16-Nov-86 22:29")

          (* * Return the variable stored as the Var for TypeName's record.)



          (* * kirk 26Feb86 Replaced NIL DEC in RECORDACCESS call with RECLOOK)



          (* * rht 8/25/86: Changed RECORDACCESS to slightly less scuzzy call to NC.GetCardTypeField, the advantage is that 
	  the latter will force autoload if necessary.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (if (NCP.CardTypeP TypeName)
	then (if (NCP.ValidCardTypeVar Var)
		   then (EVAL (BQUOTE (NC.GetCardTypeField , Var TypeName)))
		 else (NCP.ReportError "NCP.CardTypeVar" (CONCAT Var 
						      " is not a kind of Var for NoteCard types.")))
      else (NCP.ReportError "NCP.CardTypeVar" (CONCAT TypeName 
							    " is not a loaded NoteCard type."))
	     NIL)))

(NCP.CardTypeDisplayedInMenu
  (LAMBDA Args                                               (* rht: "16-Nov-86 22:00")

          (* * Expects one or two args: CardType and optional new value for CardDisplayedInMenuFlg. Always returns the old 
	  value of CardDisplayedInMenuFlg for given card type.)



          (* * rht 7/15/86: Changed to call NCP.ChangeCardTypeFields)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (LET (CardType OldVal)
         (if (OR (EQ Args 1)
		     (EQ Args 2))
	     then (if (NCP.CardTypeP (SETQ CardType (ARG Args 1)))
			then (PROG1 (SETQ OldVal (NCP.CardTypeVar CardType (QUOTE 
									       DisplayedInMenuFlg)))
					(if (AND (EQ Args 2)
						     (NEQ OldVal (EQ Args 2)))
					    then (NCP.ChangeCardTypeFields
						     CardType NIL (BQUOTE ((DisplayedInMenuFlg
									       ,
									       (EQ Args 2)))))))
		      else (NCP.ReportError "NCP.CardTypeDisplayedInMenu" (CONCAT CardType 
								" is not a loaded NoteCard type."))
			     NIL)
	   else (NCP.ReportError "NCP.CardTypeDisplayedInMenu" 
				     "Improper number of args to NCP.CardTypeDisplayedInMenu.")
		  NIL))))

(NCP.IsSubTypeOfP
  (LAMBDA (SubTypeName SupposedSuperTypeName)                (* rht: "16-Nov-86 22:30")

          (* * Return non-nil if SubTypeName inherits somewhere up the hierarchy from SupposedSuperTypeName)



          (* * rht 8/19/86: Fixed typo bug.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (if (NCP.CardTypeP SubTypeName)
	then (NC.IsSubTypeOfP SubTypeName SupposedSuperTypeName)
      else (NCP.ReportError "NCP.IsSubTypeOfP" (CONCAT SubTypeName 
							     " is not a loaded notecard type.")))))

(NCP.TextBasedP
  (LAMBDA (CardOrCardType)                                   (* rht: "16-Nov-86 22:30")

          (* * This card or card type is a subtype of Text.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (LET ((CardType (if (NC.CardP CardOrCardType)
			then (NCP.CardType CardOrCardType)
		      else CardOrCardType)))
         (if (NCP.CardTypeP CardType)
	     then (NC.IsSubTypeOfP CardType (QUOTE Text))
	   else (NCP.ReportError "NCP.TextBasedP" (CONCAT CardType 
								" is not a loaded notecard type.")))))
)

(NCP.SketchBasedP
  (LAMBDA (CardOrCardType)                                   (* rht: "16-Nov-86 22:30")

          (* * This card type is a subtype of Sketch.)



          (* * rht 10/15/86: Fixed typo.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (LET ((CardType (if (NC.CardP CardOrCardType)
			then (NCP.CardType CardOrCardType)
		      else CardOrCardType)))
         (if (NCP.CardTypeP CardType)
	     then (NC.IsSubTypeOfP CardType (QUOTE Sketch))
	   else (NCP.ReportError "NCP.SketchBasedP" (CONCAT CardType 
								" is not a loaded notecard type.")))))
)

(NCP.GraphBasedP
  (LAMBDA (CardOrCardType)                                   (* rht: "16-Nov-86 22:31")

          (* * This card type is a subtype of Graph.)



          (* * rht 10/15/86: Fixed typo.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (LET ((CardType (if (NC.CardP CardOrCardType)
			then (NCP.CardType CardOrCardType)
		      else CardOrCardType)))
         (if (NCP.CardTypeP CardType)
	     then (NC.IsSubTypeOfP CardType (QUOTE Graph))
	   else (NCP.ReportError "NCP.GraphBasedP" (CONCAT CardType 
								" is not a loaded notecard type.")))))
)

(NCP.CreateCard
  (LAMBDA (Type NoteFile Title NoDisplayFlg Props ParentFileBoxes TypeSpecificArgs)
                                                             (* rht: "16-Nov-86 22:32")

          (* * Creates a new notecard with given type, title, props and parents. Any of those args can be nil.
	  Type being NIL will cause user to be asked. Makes a card with initially empty substance.)



          (* * rht 11/20/84: Had to add a horrible kluge: if creating a document card in which embedded links may be copied, 
	  then need to have document card visible on screen. This is because ID is currently unattainable from just the 
	  Textstream -
	  need to have a window. Until that is fixed, we temporarily bring up the document card while it's being filled in.)



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



          (* * rht 7/10/86: Ripped out the above described document kludge.)



          (* * rht 8/21/86: Now sticks (APPEND Props) on the card's proplist, i.e. a top level copy.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (if (NCP.CardTypeP Type)
	then (LET (Card CardIdentifier)
		    (if (SETQ CardIdentifier (NC.MakeNoteCard Type NoteFile Title NoDisplayFlg 
								    TypeSpecificArgs))
			then (SETQ Card (if (WINDOWP CardIdentifier)
						then (NCP.CardFromWindow CardIdentifier)
					      else CardIdentifier))
			       (if Props
				   then (NC.SetPropList Card (APPEND Props))
					  (NC.SetPropListDirtyFlg Card T))
			       (for Box in (MKLIST ParentFileBoxes)
				  do (if (NCP.FileBoxP Box)
					   then (NCP.FileCards Card Box)
					 else (NCP.ReportError "NCP.CreateCard" (CONCAT Box 
								      " not an existing filebox."))))
			       Card))
      else (NCP.ReportError "NCP.CreateCard" (CONCAT "Unknown card type: " Type))
	     NIL)))

(NCP.CreateBrowserCard
  (LAMBDA (NoteFile Title ParamList NoDisplayFlg Props ParentFileBoxes)
                                                             (* rht: "16-Nov-86 22:01")

          (* * Creates a new browser notecard with given type, title, props, parents, starting ID and link labels.)



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



          (* * rht 8/21/86: Changed call from NCP.ValidLinkType to NCP.ValidLinkTypeP.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (LET (ValidLinkTypes LinkTypes NewParamList)
         (SETQ ValidLinkTypes (for LinkType in (SETQ LinkTypes (LISTGET ParamList
										  (QUOTE LINKTYPES))
						       )
				   join (COND
					    ((EQ LinkType (QUOTE ALL))
					      (NCP.LinkTypes NoteFile))
					    ((EQ LinkType (QUOTE ←ALL))
					      (NCP.ReverseLinkTypes NoteFile))
					    ((NOT (NCP.ValidLinkTypeP LinkType NoteFile))
					      (NCP.ReportError "NCP.CreateBrowserCard"
								 (CONCAT LinkType 
									" not a valid link type."))
					      NIL)
					    (T (LIST LinkType)))))
         (SETQ ValidLinkTypes (INTERSECTION ValidLinkTypes ValidLinkTypes))
         (if (AND LinkTypes (NULL ValidLinkTypes))
	     then NIL
	   else                                            (* Make a copy of the user's param list since she may 
							     not want it to get rplaca'd.)
		  (if ParamList
		      then (SETQ NewParamList (COPY ParamList))
			     (LISTPUT NewParamList (QUOTE LINKTYPES)
					ValidLinkTypes)
		    else (SETQ NewParamList (LIST (QUOTE LINKTYPES)
							ValidLinkTypes)))
		  (NCP.CreateCard (QUOTE Browser)
				    NoteFile Title NoDisplayFlg Props ParentFileBoxes NewParamList))))
)

(NCP.MakeDocument
  (LAMBDA (NoteFile RootCard ParamProps NoDisplayFlg Props ParentFileBoxes)
                                                             (* rht: "16-Nov-86 22:03")

          (* * Do a MakeDocument starting from RootCard according to parameters in ParamProps if non-nil.
	  Otherwise use the default parameters. Note that ParamProps are *only* used for the duration of this MakeDocument 
	  and do not affect the default parameter values.)



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



          (* * rht 8/25/86: Now passes non-nil QuietFlg to NCP.UncacheCards.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (LET (CurParams DocCard WasActive)
         (if (NC.ValidCardP RootCard)
	     then (AND (NOT (SETQ WasActive (NCP.CardCachedP RootCard)))
			   (NCP.CacheCards RootCard))
		    (if ParamProps
			then (SETQ CurParams (NCP.DocumentParameters ParamProps)))
		    (SETQ DocCard (NCP.CreateCard (QUOTE Document)
						      NoteFile NIL NoDisplayFlg Props ParentFileBoxes 
						      RootCard))
		    (if ParamProps
			then (SETPROPLIST (QUOTE NC.MakeDocParameters)
					      CurParams))
		    (AND (NOT WasActive)
			   (NCP.UncacheCards RootCard T))
		    DocCard
	   else (NCP.ReportError "NCP.MakeDocument" (CONCAT RootCard 
								  " not a valid card or filebox."))
		  NIL))))

(NCP.MakeLinkIndex
  (LAMBDA (NoteFile LinkTypes BackPointersP NoDisplayFlg Props ParentFileBoxes)
                                                             (* rht: "16-Nov-86 22:05")

          (* * Do a MakeLinkIndex on LinkTypes inserting backpointers according to BackPointersP.)



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



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (LET ((ValidLinkTypes (for LinkType in (MKLIST LinkTypes)
			     join (COND
				      ((EQ LinkType (QUOTE ALL))
					(NCP.LinkTypes NoteFile))
				      ((EQ LinkType (QUOTE ←ALL))
					(NCP.ReverseLinkTypes NoteFile))
				      ((NOT (NCP.ValidLinkType LinkType NoteFile))
					(NCP.ReportError "NCP.MakeLinkIndex" (CONCAT LinkType 
								       " not a valid link label."))
					NIL)
				      (T (LIST LinkType))))))
         (SETQ ValidLinkTypes (INTERSECTION ValidLinkTypes ValidLinkTypes))
         (if (AND LinkTypes (NULL ValidLinkTypes))
	     then NIL
	   else (NCP.CreateCard (QUOTE LinkIndex)
				    NoteFile NIL NoDisplayFlg Props ParentFileBoxes (LIST 
										   ValidLinkTypes 
										    BackPointersP)))))
)

(NCP.OpenCard
  (LAMBDA (Card Region/Position TypeSpecificArgs)            (* rht: "16-Nov-86 22:32")

          (* * Cache this card, if necessary, and display on the screen.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (if (NC.ValidCardP Card)
	then (LET ((OldProc (TTY.PROCESS)))
		    (PROG1 (NC.EditNoteCard Card Region/Position TypeSpecificArgs)
			     (AND (PROCESSP OldProc)
				    (TTY.PROCESS OldProc))))
      else (NCP.ReportError "NCP.OpenCard" (CONCAT Card " not an existing card or box.")))))

(NCP.CloseCards
  (LAMBDA (Cards QuietFlg)                                   (* rht: "16-Nov-86 22:06")

          (* * Uncache and undisplay any active cards in Cards)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (for Card in (MKLIST Cards) bind Win (OldProc ←(TTY.PROCESS))
       do (if (NOT (NC.ValidCardP Card))
		then (NCP.ReportError "NCP.CloseCards" (CONCAT Card 
							      " not an existing card or filebox."))
	      elseif (AND (NCP.CardCachedP Card)
			      (NEQ (NC.QuitCard Card T NIL NIL NIL NIL NIL QuietFlg)
				     (QUOTE DON'T))
			      (SETQ Win (NC.FetchWindow Card)))
		then (bind (Process ←(WINDOWPROP Win (QUOTE PROCESS)))
			  until (OR (NULL Process)
					(PROCESS.FINISHEDP Process))
			  do (BLOCK)))
       finally (AND (PROCESSP OldProc)
			(TTY.PROCESS OldProc))
		 (RETURN Card))))

(NCP.DisplayCard
  (LAMBDA (Card Region/Position TypeSpecificArgs)            (* rht: "16-Nov-86 22:33")

          (* * display Card on the screen.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (if (NC.ValidCardP Card)
	then (if (NCP.CardCachedP Card)
		   then (LET ((OldProc (TTY.PROCESS)))
			       (PROG1 (NC.EditNoteCard Card Region/Position TypeSpecificArgs)
					(AND (PROCESSP OldProc)
					       (TTY.PROCESS OldProc))))
		 else (NCP.ReportError "NCP.DisplayCard" (CONCAT Card 
					     " must be cached before displayed: NCP.DisplayCard.")))
      else (NCP.ReportError "NCP.DisplayCard" (CONCAT Card " not an existing card or box.")))))

(NCP.UndisplayCards
  (LAMBDA (Cards QuietFlg WriteChangesFlg)                   (* rht: "16-Nov-86 22:06")

          (* * If card is valid and displayed, then undisplay it but leave it cached. If WriteChangesFlg is non-nil, then 
	  save changes to the file, otherwise saving will wait until card is uncached.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (for Card in (MKLIST Cards) do (COND
					     ((NOT (NC.ValidCardP Card))
					       (NCP.ReportError "NCP.UndisplayCards"
								  (CONCAT Card 
							      " not an existing card or filebox.")))
					     ((NOT (NCP.CardDisplayedP Card))
					       (NCP.PrintMsg NIL T Card 
						       " already undisplayed: NCP.UndisplayCards"))
					     (T (LET ((OldProc (TTY.PROCESS)))
						     (PROG1 (NC.QuitCard Card T NIL (NOT 
										  WriteChangesFlg)
									     NIL NIL NIL QuietFlg T)
							      (AND (PROCESSP OldProc)
								     (TTY.PROCESS OldProc))))))
       finally (RETURN Card))))

(NCP.CacheCards
  (LAMBDA (Cards)                                            (* rht: "16-Nov-86 22:06")

          (* * Cache all the info for any inactive cards in Cards)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (for Card in (MKLIST Cards) do (COND
					     ((NOT (NC.ValidCardP Card))
					       (NCP.ReportError "NCP.CacheCards" (CONCAT Card 
							      " not an existing card or filebox.")))
					     ((NCP.CardCachedP Card)
					       (NCP.PrintMsg NIL T Card 
							       " already cached: NCP.CacheCards."))
					     (T (NC.GetNoteCard Card)))
       finally (RETURN Card))))

(NCP.UncacheCards
  (LAMBDA (Cards QuietFlg)                                   (* rht: "16-Nov-86 22:34")

          (* * Uncache and undisplay any active cards in Cards)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (for Card in (MKLIST Cards) do (COND
					     ((NOT (NC.ValidCardP Card))
					       (NCP.ReportError "NCP.UncacheCards"
								  (CONCAT Card 
							      " not an existing card or filebox.")))
					     ((NOT (NCP.CardCachedP Card))
					       (NCP.ReportError "NCP.UncacheCards"
								  (CONCAT Card 
							    " must be cached before can uncache.")))
					     ((NCP.CardDisplayedP Card)
					       (NCP.ReportError "NCP.UncacheCards"
								  (CONCAT Card 
						       " must be undisplayed before can uncache.")))
					     (T (NC.QuitCard Card NIL NIL NIL NIL NIL NIL QuietFlg))
					     ))))

(NCP.CardTitle
  (LAMBDA Args                                               (* rht: "16-Nov-86 22:08")

          (* * Expects one or two args, the Card and an optional new title. If the latter is present then change the title of
	  ID. In any case, return the old title.)



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



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (LET (Card)
         (COND
	   ((AND (NEQ Args 1)
		   (NEQ Args 2))
	     (NCP.ReportError "NCP.CardTitle" "Improper number of arguments to NCP.CardBoxTitle.")
	     NIL)
	   ((NC.ValidCardP (SETQ Card (ARG Args 1)))
	     (PROG1 (NC.RetrieveTitle Card)
		      (if (EQ Args 2)
			  then (NC.AssignTitle Card NIL (ARG Args 2)))))
	   (T (NCP.ReportError "NCP.CardTitle" (CONCAT Card " not an existing card or box."))
	      NIL)))))

(NCP.FileCards
  (LAMBDA (CardBoxList BoxList)                              (* rht: "16-Nov-86 22:08")

          (* * File every card or box in CardBoxList in every box in BoxList. Either arg can be an atom or list.
	  Check for cycles.)



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



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (SETQ CardBoxList (for Card in (MKLIST CardBoxList)
			   unless (if (NOT (NC.ValidCardP Card))
					then (NCP.ReportError "NCP.FileCards" (CONCAT Card 
						     " not an existing card or box.  Can't file."))
					       T)
			   collect Card))
    (SETQ BoxList (for Card in (MKLIST BoxList) unless (if (NOT (NCP.FileBoxP Card))
								     then (NCP.ReportError
									      "NCP.FileCards"
									      (CONCAT Card 
						" not an existing filebox.  Can't be filed into."))
									    T)
		       collect Card))
    (if (AND BoxList CardBoxList)
	then (for Box in BoxList when (NC.FileBoxCollectChildren NIL Box CardBoxList T)
		  collect Box)
      else NIL)))

(NCP.UnfileCards
  (LAMBDA (CardBoxList BoxList)                              (* rht: "16-Nov-86 22:09")

          (* * Unfile every card or box in CardBoxList from every box in BoxList. Either arg can be a litatom ID.
	  Either can also be the litatom ALL. If CardBoxList is ALL then clear out all children from every element of 
	  BoxList. If BoxList is ALL then unlink all parents of every element of CardBoxList.)



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



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (if (NEQ CardBoxList (QUOTE ALL))
	then (SETQ CardBoxList (for Card in (MKLIST CardBoxList)
				      unless (if (NOT (NC.ValidCardP Card))
						   then (NCP.ReportError "NCP.UnfileCards"
									     (CONCAT Card 
						   " not an existing card or box.  Can't unfile."))
							  T)
				      collect Card)))
    (if (NEQ BoxList (QUOTE ALL))
	then (SETQ BoxList (for Card in (MKLIST BoxList)
				  unless (if (NOT (NCP.FileBoxP Card))
					       then (NCP.ReportError "NCP.UnfileCards"
									 (CONCAT Card 
								      " not an existing filebox."))
						      T)
				  collect Card)))
    (if (NEQ CardBoxList (QUOTE ALL))
	then (if (EQ BoxList (QUOTE ALL))
		   then                                    (* Unfile every element of CardBoxList from all its 
							     parents.)
			  (for Card in CardBoxList do (NCP.DeleteLinks (NCP.GetLinks
										 NIL Card
										 (LIST 
									    NC.FiledCardLinkLabel 
									       NC.SubBoxLinkLabel))))
		 else                                      (* Unfile every element of CardBoxList from a 
							     selection of its parents.)
			(for Card in CardBoxList do (for Box in BoxList
							     do (NCP.DeleteLinks
								    (NCP.GetLinks Box Card
										    (LIST 
									    NC.FiledCardLinkLabel 
									       NC.SubBoxLinkLabel)))))
		     )
      else (if (EQ BoxList (QUOTE ALL))
		 then (SETQ BoxList (NCP.AllBoxes)))
	     (for Box in BoxList do (NCP.DeleteLinks (NCP.GetLinks Box NIL
									     (LIST 
									    NC.FiledCardLinkLabel 
									       NC.SubBoxLinkLabel)))))
    (AND CardBoxList BoxList)))

(NCP.CardParents
  (LAMBDA (Card)                                             (* rht: "16-Nov-86 22:35")

          (* * Return the list of fileboxes in which Card has been filed.)



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



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (if (NC.ValidCardP Card)
	then (for Link in (NCP.GetLinks NIL Card (LIST NC.FiledCardLinkLabel 
								 NC.SubBoxLinkLabel))
		  collect (fetch (Link SourceCard) of Link))
      else (NCP.ReportError "NCP.CardParents" (CONCAT Card 
							   " is not an existing card or filebox.")))))

(NCP.FileBoxChildren
  (LAMBDA (Box)                                              (* rht: "16-Nov-86 22:35")

          (* * Return the list of children of Box in proper order.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (COND
      ((NCP.FileBoxP Box)
	(for Link in (NCP.GetLinks Box NIL (LIST NC.FiledCardLinkLabel NC.SubBoxLinkLabel))
	   collect (fetch (Link DestinationCard) of Link)))
      (T (NCP.ReportError "NCP.FileBoxChildren" (CONCAT Box " is not an existing filebox."))))))

(NCP.GetLinks
  (LAMBDA (Cards DestinationCards Labels NoteFile)           (* rht: "16-Nov-86 22:10")

          (* * Returns a list of all links from Cards to DestinationCards whose link label is one of Labels.
	  Labels can be nil, in which case all such links are returned. Cards and DestinationCards can each be atomic.
	  Each can also be nil. For example, if DestinationCards is nil, then all links pointing from Cards to anywhere with 
	  given labels are returned. Note that if both Cards and DestinationCards are nil, then will return all links whose 
	  label is one of Labels. If all three args are nil, then return all links in the current notefile.)



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



          (* * rht 8/29/86: Now blocks in loops and checks whether links cached before retrieving.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (LET (ValidCards ValidDestinationCards)
         (SETQ Labels (MKLIST Labels))
         (SETQ ValidCards (for Card in (MKLIST Cards) eachtime (BLOCK)
			       unless (COND
					  ((NOT (NC.ValidCardP Card))
					    (NCP.ReportError "NCP.GetLinks" (CONCAT Card 
								  " not an existing card or box."))
					    T))
			       collect Card))
         (SETQ ValidDestinationCards (for Card in (MKLIST DestinationCards) eachtime
										     (BLOCK)
					  unless (COND
						     ((NOT (NC.ValidCardP Card))
						       (NCP.ReportError "NCP.GetLinks"
									  (CONCAT Card 
								  " not an existing card or box."))
						       T))
					  collect Card))
         (COND
	   (Cards (for Card in ValidCards eachtime (BLOCK)
		     join (LET ((HadLinksCachedFlg (NC.LinksCachedP Card)))
			         (PROG1 (for Link in (NC.RetrieveToLinks Card)
					     when (COND
						      (DestinationCards (FMEMB (fetch
										   (Link 
										  DestinationCard)
										    of Link)
										 
									    ValidDestinationCards))
						      (T T))
					     when (COND
						      (Labels (FMEMB (fetch (Link Label)
									  of Link)
								       Labels))
						      (T T))
					     collect Link)
					  (OR HadLinksCachedFlg (NC.UncacheLinks Card))))))
	   (DestinationCards (for Card in ValidDestinationCards eachtime (BLOCK)
				join (LET ((HadLinksCachedFlg (NC.LinksCachedP Card)))
					    (PROG1 (for Link in (NC.RetrieveFromLinks Card)
							when (COND
								 (Labels (FMEMB
									   (fetch (Link Label)
									      of Link)
									   Labels))
								 (T T))
							collect Link)
						     (OR HadLinksCachedFlg (NC.UncacheLinks
							     Card))))))
	   (T (NCP.MapLinks NoteFile (FUNCTION PROG1)
			    (FUNCTION (LAMBDA (Link)
				(if Labels
				    then (FMEMB (fetch (Link Label) of Link)
						    Labels)
				  else T)))))))))

(NCP.CardProp
  (LAMBDA Args                                               (* rht: "16-Nov-86 22:11")

          (* * Expects two or three arguments: ID, Property, and optional new value. Returns the old value.
	  Assigns the new value if given. Semantics are just like WINDOWPROP.)



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



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (LET (Card PropList)
         (COND
	   ((AND (NEQ Args 2)
		   (NEQ Args 3))
	     (NCP.ReportError "NCP.CardProp" (CONCAT "Improper number of args: " Args))
	     NIL)
	   ((NC.ValidCardP (SETQ Card (ARG Args 1)))
	     (PROG1 (LISTGET (SETQ PropList (NC.RetrievePropList Card))
				 (ARG Args 2))
		      (if (EQ Args 3)
			  then (if PropList
				     then (LISTPUT PropList (ARG Args 2)
						       (ARG Args 3))
				   else (NC.SetPropList Card (LIST (ARG Args 2)
									 (ARG Args 3))))
				 (if (NOT (NCP.CardCachedP Card))
				     then (NC.PutPropList Card)
				   else (NC.SetPropListDirtyFlg Card T)))))
	   (T (NCP.ReportError "NCP.CardProp" (CONCAT Card " not an existing card or box."))
	      NIL)))))

(NCP.CardAddProp
  (LAMBDA (Card Property ItemToAdd)                          (* rht: "16-Nov-86 22:12")

          (* * Adds ItemToAdd to the value of ID's Property property. Returns the old value. Same semantics as 
	  WINDOWADDPROP.)



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



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (if (NC.ValidCardP Card)
	then (LET* ((PropList (NC.RetrievePropList Card))
		      (OldPropValue (LISTGET PropList Property)))
		     (if (NOT (FMEMB ItemToAdd (MKLIST OldPropValue)))
			 then (LISTPUT PropList Property (APPEND (MKLIST OldPropValue)
								       (LIST ItemToAdd)))
				(if (NOT (NCP.CardCachedP Card))
				    then (NC.PutPropList Card)
				  else (NC.SetPropListDirtyFlg Card T)))
		 OldPropValue)
      else (NCP.ReportError "NCP.CardAddProp" (CONCAT Card " not an existing card or box."))
	     NIL)))

(NCP.CardDelProp
  (LAMBDA (Card Property ItemToDelete)                       (* rht: "16-Nov-86 22:12")

          (* * Deletes ItemToDelete from the Property prop of Card if it is there, returning the previous list.
	  If it's not there, then return NIL. Same semantics as WINDOWDELPROP.)



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



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (if (NC.ValidCardP Card)
	then (LET* ((PropList (NC.RetrievePropList Card))
		      (OldPropValue (LISTGET PropList Property)))
		     (COND
		       ((NLISTP OldPropValue)
			 NIL)
		       ((FMEMB ItemToDelete OldPropValue)
			 (LISTPUT PropList Property (for Item in OldPropValue
							 unless (EQ Item ItemToDelete)
							 collect Item))
			 (if (NOT (NCP.CardCachedP Card))
			     then (NC.PutPropList Card)
			   else (NC.SetPropListDirtyFlg Card T))
			 OldPropValue)
		       (T NIL)))
      else (NCP.ReportError "NCP.CardDelProp" (CONCAT Card " not an existing card or box."))
	     NIL)))

(NCP.CardSubstance
  (LAMBDA Args                                               (* rht: "16-Nov-86 22:13")

          (* * Return the substance for this card.)



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



          (* * rht 8/8/86: Now can accept one or two args. Always returns old substance, but will replace substance with 
	  second arg if present.)



          (* * 8/25/86: Now passes non-nil QuietFlg to NCP.CloseCards.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (LET (Card)
         (COND
	   ((AND (NEQ Args 1)
		   (NEQ Args 2))
	     (NCP.ReportError "NCP.CardSubstance" (CONCAT "Improper number of args: " Args))
	     NIL)
	   ((NCP.ValidCardP (SETQ Card (ARG Args 1)))
	     (LET (WasActive)
	          (OR (SETQ WasActive (NCP.CardCachedP Card))
			(NCP.CacheCards Card))
	          (PROG1 (NC.FetchSubstance Card)
			   (if (EQ Args 2)
			       then (NC.SetSubstance Card (ARG Args 2))
				      (NCP.MarkCardDirty Card))
			   (OR WasActive (NCP.CloseCards Card T)))))
	   (T (NCP.ReportError "NCP.CardSubstance" (CONCAT Card " not an existing card."))
	      NIL)))))

(NCP.CardRegion
  (LAMBDA (Card)                                             (* rht: "16-Nov-86 22:13")

          (* * Return the substance for this card.)



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



          (* * rht 8/25/86: Now passes non-nil QuietFlg to NCP.UncacheCards.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (if (NC.ValidCardP Card)
	then (LET (WasActive)
		    (OR (SETQ WasActive (NCP.CardCachedP Card))
			  (NCP.CacheCards Card))
		    (PROG1 (NC.FetchRegion Card)
			     (OR WasActive (NCP.UncacheCards Card T))))
      else (NCP.ReportError "NCP.CardRegion" (CONCAT Card " not an existing card."))
	     NIL)))

(NCP.CardAddText
  (LAMBDA (Card Text Loc)                                    (* rht: "16-Nov-86 22:14")

          (* * Adds the Text to ID's window at the given Loc. Loc defaults to the current cursor position.)



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



          (* * rht 8/25/86: Now passes non-nil QuietFlg to NCP.UncacheCards.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (PROG (WasActiveP)
	    (if (NOT (NC.ValidCardP Card))
		then (NCP.ReportError "NCP.CardAddText" (CONCAT Card 
							   " is not an existing card or filebox."))
		       (RETURN NIL))
	    (if (NOT (NCP.TextBasedP (NCP.CardType Card)))
		then (NCP.ReportError "NCP.CardAddText" 
					  "Can only add text to cards with type Text.")
		       (RETURN NIL))
	    (if (NOT (SETQ WasActiveP (NCP.CardCachedP Card)))
		then (NCP.CacheCards Card))
	    (NCP.ChangeLoc Card Loc)
	    (TEDIT.INSERT (NC.FetchSubstance Card)
			    Text)
	    (NC.MarkCardDirty Card)
	    (if (NOT WasActiveP)
		then (NCP.UncacheCards Card T))
	    (RETURN Card))))

(NCP.ChangeLoc
  (LAMBDA (Card Loc)                                         (* rht: "16-Nov-86 22:15")

          (* * Changes the location within ID's textstream to the new loc Loc. Loc can be the litatoms START or END, a 
	  number, or nil. The latter indicates to use the current cursor position. Note that we don't mark card as dirty just
	  because its selection changed. Note that this leaves card active even if inactive when we were called.)



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



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (if (AND (NC.ValidCardP Card)
		 (NCP.TextBasedP Card))
	then (if (NOT (NCP.CardCachedP Card))
		   then (NCP.CacheCards Card))
	       (LET ((Stream (NC.FetchSubstance Card)))
		    (SELECTQ Loc
			       ((START 0)
				 (TEDIT.SETSEL Stream 0 0 (QUOTE RIGHT)))
			       (END (TEDIT.SETSEL Stream (ADD1 (fetch (TEXTOBJ TEXTLEN)
								      of (TEXTOBJ Stream)))
						    0
						    (QUOTE RIGHT)))
			       (AND (FIXP Loc)
				      (GEQ Loc 0)
				      (TEDIT.SETSEL Stream Loc 0 (QUOTE RIGHT))))
		Card)
      else (NCP.ReportError "NCP.ChangeLoc" (CONCAT Card 
						      " not an existing card or not TEdit based."))
	     NIL)))

(NCP.DeleteCards
  (LAMBDA (Cards)                                            (* rht: "16-Nov-86 22:15")

          (* * Delete the given cards and boxes. Or just one, if Cards is atomic.)



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



          (* * rht 11/7/86: Now passes flg args to NC.DeleteNoteCards to prevent confirm messages to user.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (SETQ Cards (for Card in (MKLIST Cards) unless (if (NOT (NC.ValidCardP Card))
								 then (NCP.ReportError
									  "NCP.DeleteCards"
									  (CONCAT Card 
							       " is not an existing card or box."))
									T)
		     collect Card))
    (AND Cards (NC.DeleteNoteCards Cards T NIL NIL T T))))

(NCP.SameCardP
  (LAMBDA (Card1 Card2)                                      (* rht: "16-Nov-86 22:36")

          (* * Returns non-nil if two cards are the same.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (if (AND (NCP.ValidCardP Card1)
		 (NCP.ValidCardP Card2))
	then (NC.SameCardP Card1 Card2)
      else (NCP.ReportError "NCP.SameCardP" (CONCAT "Args not valid cards: " Card1 Card2)))))

(NCP.CreateLink
  (LAMBDA (Source Destination LinkType DisplayMode)          (* rht: "16-Nov-86 22:37")

          (* * Create a link from Source to Destination. Source can be a card or a list of two things;
	  card and location spec. Location spec can be as in NCP.ChangeLoc documentation with the added option of the atom 
	  GLOBAL meaning that this should be a global link.)


    (LET (SourceLoc SourceCard)
         (COND
	   ((NC.ValidCardP Source)
	     (NCP.LocalGlobalLink LinkType Source Destination NIL DisplayMode))
	   ((OR (NOT (NC.ValidCardP (SETQ SourceCard (CAR Source))))
		  (NLISTP Source)
		  (NULL (CDR Source)))
	     (NCP.ReportError "NCP.CreateLink" (CONCAT 
			  "'Source' arg is not either a card or a list of card and atom or num: "
							   Source)))
	   ((EQ (SETQ SourceLoc (CADR Source))
		  (QUOTE GLOBAL))
	     (NCP.GlobalGlobalLink LinkType SourceCard Destination))
	   ((OR (FMEMB (CADR Source)
			   (QUOTE (START END NIL)))
		  (FIXP SourceLoc))
	     (NCP.LocalGlobalLink LinkType SourceCard Destination SourceLoc DisplayMode))
	   (T (NCP.ReportError "NCP.CreateLink" (CONCAT 
			  "'Source' arg is not either a card or a list of card and atom or num: "
							    Source)))))))

(NCP.LocalGlobalLink
  (LAMBDA (LinkType SourceCard DestinationCard FromLoc DisplayMode)
                                                             (* rht: "16-Nov-86 22:17")

          (* * Create a link from within the text of the SourceCard card to the DestinationCard card.)



          (* * rht 4/1/85: Changed to handle old-style link display modes.)



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



          (* * rht 8/25/86: Now passes non-nil QuietFlg to NCP.UncacheCards.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (PROG ((CoercedDisplayMode (NCP.CoerceToLinkDisplayMode (OR DisplayMode (NCP.CardType
									SourceCard))))
	     WasActive NoteFile)
	    (if (NULL CoercedDisplayMode)
		then (NCP.ReportError "NCP.LocalGlobalLink" (CONCAT DisplayMode 
								 " is invalid link display mode."
									  (CHARACTER 13)
									  "No link created."))
		       (RETURN NIL))
	    (if (EQ LinkType NC.FiledCardLinkLabel)
		then (if (AND (NOT (NCP.FileBoxP DestinationCard))
				    (NCP.FileBoxP SourceCard))
			   then (OR (SETQ WasActive (NCP.CardCachedP SourceCard))
					(NCP.CacheCards SourceCard))
				  (NCP.ChangeLoc SourceCard FromLoc)
				  (NCP.FileCards DestinationCard SourceCard)
				  (RETURN (PROG1 (CAR (NCP.GetLinks SourceCard 
									    DestinationCard 
									    NC.FiledCardLinkLabel))
						     (OR WasActive (NCP.UncacheCards SourceCard T)
							   )))
			 else (NCP.ReportError "NCP.LocalGlobalLink" (CONCAT 
						   "FiledCard link must be from a box to a card."
										   (CHARACTER
										     13)
										   "No link created.")
						   )
				(RETURN NIL)))
	    (if (EQ LinkType NC.SubBoxLinkLabel)
		then (if (AND (NCP.FileBoxP DestinationCard)
				    (NCP.FileBoxP SourceCard))
			   then (OR (SETQ WasActive (NCP.CardCachedP SourceCard))
					(NCP.CacheCards SourceCard))
				  (NCP.ChangeLoc SourceCard FromLoc)
				  (NCP.FileCards DestinationCard SourceCard)
				  (RETURN (PROG1 (CAR (NCP.GetLinks SourceCard 
									    DestinationCard 
									    NC.SubBoxLinkLabel))
						     (OR WasActive (NCP.UncacheCards SourceCard T)
							   )))
			 else (NCP.ReportError "NCP.LocalGlobalLink" (CONCAT 
						       "SubBox link must be from a box to a box."
										   (CHARACTER
										     13)
										   "No link created.")
						   )
				(RETURN NIL)))             (* Inserting non-hierarchical link into a filebox.)
	    (if (NCP.FileBoxP SourceCard)
		then (NCP.ReportError "NCP.LocalGlobalLink" (CONCAT 
				 "Local links from fileboxes must be either SubBox or FiledCard."
									  (CHARACTER 13)
									  "No link created."))
		       (RETURN NIL))
	    (if (NOT (FMEMB LinkType (NCP.LinkTypes (SETQ NoteFile (fetch (Card NoteFile)
										of SourceCard)))))
		then (if (NC.AskYesOrNo (CONCAT 
						   "That link type hasn't been used in NoteFile "
							(fetch (NoteFile FullFileName)
							   of NoteFile)
							(CHARACTER 13)
							"Want to create a new link type: " LinkType 
							"? ")
					      "--" NIL T (NC.AttachPromptWindow
						(WFROMMENU (fetch (NoteFile Menu) of NoteFile)))
					      NIL NIL)
			   then (NCP.CreateLinkType LinkType NoteFile)
			 else (RETURN NIL)))
	    (OR (SETQ WasActive (NCP.CardCachedP SourceCard))
		  (NCP.CacheCards SourceCard))
	    (AND FromLoc (NCP.ChangeLoc SourceCard FromLoc))
	    (RETURN (PROG1 (NC.InsertLinkInText (NC.FetchSubstance SourceCard)
						      LinkType DestinationCard SourceCard 
						      CoercedDisplayMode)
			       (OR WasActive (NCP.UncacheCards SourceCard T)))))))

(NCP.GlobalGlobalLink
  (LAMBDA (LinkType FromCard ToCard)                         (* rht: "16-Nov-86 22:17")

          (* * This builds a global link of type LinkType between FromCard and ToID. Complains if link type is system-defined
	  with restricted semantics. If LinkType is brand new, then asks if user wants to create a new label by that name.)



          (* * rht 11/18/85: Updated to handle new notefile and card object formats.)



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



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (LET ((NoteFile (fetch (Card NoteFile) of FromCard))
	  LinkTypes)
         (SETQ LinkTypes (NCP.UserLinkTypes NoteFile))
         (COND
	   ((OR (EQ LinkType NC.SourceLinkLabel)
		  (FMEMB LinkType LinkTypes))

          (* * LinkType type is okay so create the link.)


	     (NC.MakeGlobalLink NIL LinkType ToCard FromCard))
	   ((FMEMB (U-CASE LinkType)
		     NC.UCASESystemLinkLabels)
	     (NCP.ReportError "NCP.GlobalGlobalLink" (CONCAT 
						    "Can't make a global-to-global link of type "
								 LinkType "."))
	     NIL)
	   ((NC.AskYesOrNo (CONCAT "That link type hasn't been used in this NoteFile."
				       (CHARACTER 13)
				       "Want to create a new link type: " LinkType "? ")
			     "--" NIL T (NC.AttachPromptWindow (WFROMMENU (fetch (NoteFile
											 Menu)
										 of NoteFile)))
			     NIL NIL)
	     (NCP.CreateLinkType LinkType NoteFile)

          (* * LinkType type is okay so create the link.)


	     (NC.MakeGlobalLink NIL LinkType ToCard FromCard))
	   (T NIL)))))

(NCP.GlobalLocalLink
  (LAMBDA (LinkType FromCard ToCard ToLoc)                   (* rht: "16-Nov-86 22:37")

          (* * Builds a link from the FromID card as a whole to within the text of the ToID card.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (NCP.ReportError "NCP.GlobalLocalLink" "Sorry, can't make global to local links yet.")))

(NCP.LocalLocalLink
  (LAMBDA (LinkType FromCard ToCard FromLoc ToLoc)           (* rht: "16-Nov-86 22:38")

          (* * Builds a link from within the text of the FromID card to within the text of the ToID card.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (NCP.ReportError "NCP.LocalLocalLink" "Sorry, can't make local to local links yet.")))

(NCP.LinkDesc
  (LAMBDA (Link)                                             (* rht: "16-Nov-86 22:38")

          (* * Return a list structure which describes Link. It consists of (label <fromdesc> <todesc>) where <fromdesc> and 
	  <todesc> describe the anchoring of the link at each end. They each have the form: (<anchormode> <ID> <loc>))



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (COND
      ((NCP.ValidLink Link)
	(LIST (fetch (Link Label) of Link)
		(NCP.LinkAnchorDesc Link NIL)
		(NCP.LinkAnchorDesc Link T)))
      (T (NCP.ReportError "NCP.LinkDesc" (CONCAT "No such link: " Link))))))

(NCP.LinkDisplayMode
  (LAMBDA Args                                               (* rht: "16-Nov-86 22:19")

          (* * Takes either 1 or 2 args. The first is a link, the second an optional new link display mode.
	  Return old display mode in any case; change mode if the second arg is present.)



          (* * rht 7/12/86: Now takes a list of three elements for new displaymode rather than an instance of the 
	  LINKDISPLAYMODE record. Also calls NCP.CoerceToLinkDisplayMode.)



          (* * rht 8/25/86: Now passes non-nil QuietFlg to NCP.UncacheCards.)


    (LET (Link NewMode WasActiveFlg SourceCard)
         (COND
	   ((AND (NEQ Args 1)
		   (NEQ Args 2))
	     (NCP.ReportError "NCP.LinkDisplayMode" (CONCAT "Improper number of args: " Args))
	     NIL)
	   ((NCP.ValidLink (SETQ Link (ARG Args 1)))
	     (PROG1 (fetch (Link DisplayMode) of Link)
		      (if (EQ Args 2)
			  then (if (SETQ NewMode (NCP.CoerceToLinkDisplayMode (ARG Args 2)))
				     then (OR (SETQ WasActiveFlg (NCP.CardCachedP
						      (SETQ SourceCard (fetch (Link SourceCard)
									    of Link))))
						  (NCP.CacheCards SourceCard))
					    (NC.ChangeLinkDisplayMode Link NIL NewMode)
					    (OR WasActiveFlg (NCP.UncacheCards SourceCard T))
				   else (NCP.ReportError "NCP.LinkDisplayMode"
							     (CONCAT (ARG Args 2)
								       
								 " is invalid link display mode.")))))
	     )
	   (T (NCP.ReportError "NCP.LinkDisplayMode" (CONCAT Link " is not a valid link."))
	      NIL)))))

(NCP.LinkType
  (LAMBDA Args                                               (* rht: "16-Nov-86 22:20")

          (* * Takes either 1 or 2 args. The first is a link, the second an optional new label. Return old label in any case;
	  change label if the second arg is present.)



          (* * rht 2/8/85: Now makes sure source card of link is active before calling NC.RelabelLink.)



          (* * rht 8/25/86: Now passes non-nil QuietFlg to NCP.UncacheCards.)


    (LET (Link NewLinkType SourceCard NoteFile)
         (COND
	   ((AND (NEQ Args 1)
		   (NEQ Args 2))
	     (NCP.ReportError "NCP.LinkType" (CONCAT "Improper number of args: " Args))
	     NIL)
	   ((NCP.ValidLink (SETQ Link (ARG Args 1)))
	     (PROG1 (fetch (Link Label)
			       Link)
		      (if (EQ Args 2)
			  then (COND
				   ((FMEMB (SETQ NewLinkType (ARG Args 2))
					     NC.SystemLinkLabels)
				     (NCP.ReportError "NCP.LinkType" (CONCAT 
							 "Can't change label to a system label: "
										 NewLinkType)))
				   ((OR (FMEMB NewLinkType (NCP.LinkTypes
						     (SETQ NoteFile (fetch (Card NoteFile)
									 of (SETQ SourceCard
										(fetch
										  (Link SourceCard)
										   of Link))))))
					  (AND (NC.AskYesOrNo (CONCAT 
					      "That link type hasn't been used in this NoteFile."
									    (CHARACTER 13)
									    
							       "Want to create a new link type: "
									    NewLinkType "? ")
								  "--" NIL T NIL NIL NIL)
						 (NCP.CreateLinkType NewLinkType NoteFile)))
				     (if (NCP.CardCachedP SourceCard)
					 then (NC.RelabelLink Link NIL NewLinkType T)
				       else (NCP.CacheCards SourceCard)
					      (NC.RelabelLink Link NIL NewLinkType T)
					      (NCP.UncacheCards SourceCard T)))))))
	   (T (NCP.ReportError "NCP.LinkType" (CONCAT Link " is not a valid link."))
	      NIL)))))

(NCP.LinkSource
  (LAMBDA (Link)                                             (* rht: "16-Nov-86 22:39")

          (* * Return the SOURCEID of Link.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (if (NCP.ValidLink Link)
	then (fetch (Link SourceCard) of Link)
      else (NCP.ReportError "NCP.LinkSource" (CONCAT Link " not an existing link.")))))

(NCP.LinkDestination
  (LAMBDA (Link)                                             (* rht: "16-Nov-86 22:39")

          (* * Return the DESTINATIONID of Link.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (COND
      ((NCP.ValidLink Link)
	(fetch (Link DestinationCard) of Link))
      (T (NCP.ReportError "NCP.LinkDestination" (CONCAT Link " not an existing link."))))))

(NCP.DeleteLinks
  (LAMBDA (Links)                                            (* rht: "16-Nov-86 22:40")

          (* * Delete each link in Links. If Links is one link, then just delete that one.)



          (* * rht 11/18/85: Updated to call new NC.DeleteLink function.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (for Link in (COND
		       ((type? Link Links)
			 (LIST Links))
		       (T Links))
       do (if (NCP.ValidLink Link)
		then (NC.DeleteLink Link)
	      else (NCP.ReportError "NCP.DeleteLinks" (CONCAT "No such link: " Link))))))

(NCP.SameLinkP
  (LAMBDA (Link1 Link2)                                      (* rht: "16-Nov-86 22:41")

          (* * Returns non-nil if two links are the same.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (if (AND (NCP.ValidLinkP Link1)
		 (NCP.ValidLinkP Link2))
	then (NC.SameCardP Link1 Link2)
      else (NCP.ReportError "NCP.SameLinkP" (CONCAT "Args not valid links: " Link1 Link2)))))

(NCP.CreateLinkType
  (LAMBDA (LinkType NoteFile)                                (* rht: "16-Nov-86 22:20")

          (* * Create a new link label unless already defined.)



          (* * rht 11/18/85: Updated to handle new notefile and card object formats.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (if (FMEMB LinkType (NCP.LinkTypes NoteFile))
	then (NCP.ReportError "NCP.CreateLinkType" (CONCAT "Link type already defined: " 
								 LinkType "."))
	       NIL
      else (NC.StoreLinkLabels NoteFile (CONS LinkType (NCP.UserLinkTypes NoteFile)))
	     LinkType)))

(NCP.DeleteLinkType
  (LAMBDA (LinkType NoteFile)                                (* rht: "16-Nov-86 22:21")

          (* * Checks for any instance of LinkType in the current database. If can't find any then delete the link label, 
	  otherwise error out.)



          (* * rht 11/18/85: Updated to handle new notefile and card object formats.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (COND
      ((NOT (FMEMB LinkType (NCP.LinkTypes NoteFile)))
	(NCP.ReportError "NCP.DeleteLinkType" (CONCAT "No such link type: " LinkType "."))
	NIL)
      ((FMEMB LinkType NC.SystemLinkLabels)
	(NCP.ReportError "NCP.DeleteLinkType" (CONCAT "Can't delete system link type: " LinkType 
							  "."))
	NIL)
      ((for Link in (NCP.AllLinks) thereis (EQ LinkType (fetch (Link Label) of Link)))
	(NCP.ReportError "NCP.DeleteLinkType" (CONCAT "Link type currently in use: " LinkType 
							  ". Can't delete."))
	NIL)
      (T (NC.StoreLinkLabels NoteFile (REMOVE LinkType (NCP.UserLinkTypes NoteFile)))
	 LinkType))))

(NCP.RenameLinkType
  (LAMBDA (OldLinkType NewLinkType NoteFile)                 (* rht: "16-Nov-86 22:22")

          (* * Renames all instances of links with OldLinkType to be NewLabel. And deletes the old label OldLabel.
	  If NewLinkType doesn't exist, create it.)



          (* * rht 11/18/85: Updated to handle new notefile and card object formats.)



          (* * rht 11/11/86: Took out ENV args to FUNCTION because they seemed to be causing stack overflows.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (LET ((LinkTypes (NCP.LinkTypes NoteFile)))
         (COND
	   ((NOT (FMEMB OldLinkType LinkTypes))
	     (NCP.ReportError "NCP.RenameLinkType" (CONCAT "No such link type: " OldLinkType "."))
	     NIL)
	   ((FMEMB OldLinkType NC.SystemLinkLabels)
	     (NCP.ReportError "NCP.RenameLinkType" (CONCAT "Can't rename system link type: " 
							       OldLinkType "."))
	     NIL)
	   ((FMEMB NewLinkType NC.SystemLinkLabels)
	     (NCP.ReportError "NCP.RenameLinkType" (CONCAT 
							 "Can't rename with a system link type: "
							       NewLinkType "."))
	     NIL)
	   (T (COND
		((NOT (FMEMB NewLinkType LinkTypes))
		  (NCP.CreateLinkType NewLinkType NoteFile)))
                                                             (* Map down all links, relabeling as appropriate.)
	      (NCP.MapLinks NoteFile (FUNCTION (LAMBDA (Link)
				(COND
				  ((EQ OldLinkType (fetch (Link Label) of Link))
				    (NCP.LinkType Link NewLinkType))))))
	      (NC.StoreLinkLabels NoteFile (REMOVE OldLinkType (NCP.UserLinkTypes NoteFile)))
	      NewLinkType)))))

(NCP.CardDates
  (LAMBDA (Card)                                             (* rht: "16-Nov-86 22:22")

          (* * Returns an instance of the NOTECARDDATES record filled in with the current dates of the card parts of Card.)



          (* * rht 8/25/86: Now passes non-nil QuietFlg to NCP.UncacheCards.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (if (NC.ValidCardP Card)
	then (LET ((WasActive (NCP.CardCachedP Card)))
		    (OR WasActive (NCP.CacheCards Card))
		    (PROG1 (create NOTECARDDATES
				       SUBSTANCEDATE ←(NC.FetchItemDate Card)
				       LINKSDATE ←(NC.FetchLinksDate Card)
				       TITLEDATE ←(NC.FetchTitleDate Card)
				       PROPLISTDATE ←(NC.FetchPropListDate Card))
			     (OR WasActive (NCP.UncacheCards Card T))))
      else (NCP.ReportError "NCP.CardDates" (CONCAT Card " not an existing card."))
	     NIL)))

(NCP.DocumentParameters
  (LAMBDA (NewProps)                                         (* rht: "16-Nov-86 22:23")

          (* * Returns the old value of the MakeDocument default parameters. If NewProps is non-nil then it should be a prop 
	  list which will be used to change some or all of the current MakeDocument parameters. Only those props whose names 
	  are valid MakeDocument parameters and whose values are permissible values for that name are used.)



          (* * rht 11/6/86: No longer checks for valid link label since that requires a notefile. Also returns just a 
	  proplist of the params that user can change.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (DECLARE (GLOBALVARS NC.MakeDocParameters))
    (LET ((OldParams (for ParamThing in NC.MakeDocParameters unless (EQ (CAR ParamThing)
										(QUOTE --DONE--))
			join (LIST (CAR ParamThing)
				       (GETPROP (QUOTE NC.MakeDocParameters)
						  (CAR ParamThing))))))
         (if NewProps
	     then (for Params on NewProps by (CDDR NewProps) bind Param NewValue 
									      LegalValues
		       do (SETQ Param (CAR Params))
			    (COND
			      ((NULL (SETQ LegalValues (CDR (FASSOC Param 
									    NC.MakeDocParameters))))
				(NCP.ReportError "NCP.DocumentParameters" (CONCAT Param 
								" not a document parameter name.")))
			      ((OR (AND (FMEMB (SETQ NewValue (CADR Params))
						     LegalValues)
					    (NEQ NewValue (QUOTE Select)))
				     (AND (LISTP NewValue)
					    (FMEMB (QUOTE Select)
						     LegalValues)))
				(PUTPROP (QUOTE NC.MakeDocParameters)
					   Param NewValue))
			      (T (NCP.ReportError "NCP.DocumentParameters"
						    (CONCAT NewValue 
							      " is not a permissible value for "
							      Param "."))))))
     OldParams)))

(NCP.NoteCardsParameters
  (LAMBDA (NewParams)                                        (* rht: "16-Nov-86 22:24")

          (* * Returns the old value of the Notecards parameters. If NewParams is non-nil then it should be a prop list which
	  will be used to change some or all of the current Notecards parameters. Only those props whose names are valid 
	  Notecards parameters and whose values are permissible values for that name are used. On NC.NoteCardsParameters's 
	  prop list under the parameter name is a list of one or two items. The first is the name of the global var.
	  The second if present, is a function of no args which returns a list of legal values for that parameter.
	  We only do type checking if that function is present.)



          (* * rht 3/20/85: Changed to use new GLOBALPARAMETER record, especially the CheckFn field.)



          (* * rht 6/12/86: Now checks first whether there's a PARAMCHECKFN before apply*'ing it.)



          (* * rht 7/12/86: Cleaned up a bit.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (LET (OldParams PropVal ParamCheckFn)
         (SETQ OldParams (for Param in NC.NoteCardsParameters
			      join (SETQ PropVal (GETPROP (QUOTE NC.NoteCardsParameters)
								Param))
				     (LIST Param (EVAL (if (LISTP PropVal)
							       then (fetch (GLOBALPARAMETER
										 PARAMGLOBALVAR)
									 of PropVal)
							     else PropVal)))))
         (if NewParams
	     then (for Params on NewParams by (CDDR NewParams) bind Param NewValue 
										GlobalVar PropVal
		       do (if (FMEMB (SETQ Param (CAR Params))
					   NC.NoteCardsParameters)
				then (SETQ NewValue (CADR Params))
				       (SETQ PropVal (GETPROP (QUOTE NC.NoteCardsParameters)
								  Param))
				       (SETQ GlobalVar (if (LISTP PropVal)
							     then (fetch (GLOBALPARAMETER 
										   PARAMGLOBALVAR)
								       of PropVal)
							   else PropVal))
				       (if (OR (ATOM PropVal)
						   (NULL (SETQ ParamCheckFn (fetch
							       (GLOBALPARAMETER PARAMCHECKFN)
										   of PropVal)))
						   (APPLY* ParamCheckFn NewValue))
					   then (SET GlobalVar NewValue)
					 else (NCP.ReportError "NCP.NoteCardsParameters"
								   (CONCAT NewValue 
							       " is not a permissible value for "
									     Param ".")))
			      else (NCP.ReportError "NCP.NoteCardsParameters" (CONCAT Param 
							       " not a Notecards parameter name.")))))
     OldParams)))

(NCP.RegisterCardByName
  (LAMBDA (Name Card)                                        (* rht: "16-Nov-86 22:41")

          (* * Hash Card under Name in Card's notefile's system registry card.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (if (NC.ValidCardP Card)
	then (NC.RegisterCardByName (fetch (NoteFile RegistryCard) of (NCP.NoteFileFromCard
										Card))
					Name Card)
      else (NCP.ReportError "NCP.RegisterCardByName" (CONCAT Card " is not a valid notecard.")))
    ))

(NCP.LookupCardByName
  (LAMBDA (Name NoteFile)                                    (* rht: "16-Nov-86 22:42")

          (* * Lookup Name in notefile's system registry card.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (if (NCP.OpenNoteFileP NoteFile)
	then (NC.LookupCardByName (fetch (NoteFile RegistryCard) of NoteFile)
				      Name)
      else (NCP.ReportError "NCP.LookupCardByName" (CONCAT NoteFile " is not an open notefile.")
				))))

(NCP.UnregisterName
  (LAMBDA (Name NoteFile)                                    (* rht: "16-Nov-86 22:42")

          (* * Lookup Name in notefile's system registry card.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (if (NCP.OpenNoteFileP NoteFile)
	then (NC.UnregisterName (fetch (NoteFile RegistryCard) of NoteFile)
				    Name)
      else (NCP.ReportError "NCP.UnregisterName" (CONCAT NoteFile " is not an open notefile.")))
    ))

(NCP.CardUserDataProp
  (LAMBDA Args                                               (* rht: "16-Nov-86 22:25")

          (* * Expects two or three arguments: Card, Property, and optional new value. Returns the old value.
	  Assigns the new value if given. Semantics are just like WINDOWPROP.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (LET (Card PropList)
         (COND
	   ((AND (NEQ Args 2)
		   (NEQ Args 3))
	     (NCP.ReportError "NCP.CardUserDataProp" (CONCAT "Improper number of args: " Args))
	     NIL)
	   ((NC.ValidCardP (SETQ Card (ARG Args 1)))
	     (PROG1 (NC.FetchUserDataProp Card (ARG Args 2))
		      (if (EQ Args 3)
			  then (NC.SetUserDataProp Card (ARG Args 2)
						       (ARG Args 3)))))
	   (T (NCP.ReportError "NCP.CardUserDataProp" (CONCAT Card 
								  " not an existing card or box."))
	      NIL)))))

(NCP.NoteFileProp
  (LAMBDA Args                                               (* rht: "16-Nov-86 22:26")

          (* * Expects two or three arguments: Notefile, Property, and optional new value. Returns the old value.
	  Assigns the new value if given. Semantics are just like WINDOWPROP.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (LET (NoteFile PropList)
         (COND
	   ((AND (NEQ Args 2)
		   (NEQ Args 3))
	     (NCP.ReportError "NCP.NoteFileProp" (CONCAT "Improper number of args: " Args))
	     NIL)
	   ((type? NoteFile (SETQ NoteFile (ARG Args 1)))
	     (PROG1 (LISTGET (SETQ PropList (fetch (NoteFile UserProps) of NoteFile))
				 (ARG Args 2))
		      (if (EQ Args 3)
			  then (if PropList
				     then (LISTPUT PropList (ARG Args 2)
						       (ARG Args 3))
				   else (replace (NoteFile UserProps) of NoteFile
					     with (LIST (ARG Args 2)
							    (ARG Args 3)))))))
	   (T (NCP.ReportError "NCP.NoteFileProp" (CONCAT NoteFile " not a valid notefile."))
	      NIL)))))
)
(DEFINEQ

(NCP.CreateCardType
  (LAMBDA (TypeName SuperType FnsAssocList VarsAssocList)    (* rht: "16-Nov-86 22:46")

          (* * Make a new card type. If there is already a card type by that name, then print message and overwrite.)



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



          (* * rht 11/16/86: Changed call to NCP.ReportWarning)


    (if (FMEMB TypeName (NCP.CardTypes))
	then (NCP.ReportWarning "NCP.CreateCardType" (CONCAT "Redefining NoteCard type: " 
								   TypeName)))
    (NC.AddCardType TypeName SuperType FnsAssocList VarsAssocList)
    TypeName))

(NCP.CreateCardTypeStub
  (LAMBDA (TypeName SuperType FullDefinitionFileName FnsAssocList VarsAssocList)
                                                             (* rht: "16-Nov-86 22:47")

          (* * Make a stub for a new card type. If there is already a card type by that name, then print message and 
	  overwrite.)



          (* * rht 11/16/86: Changed call to NCP.ReportError)


    (if (FMEMB TypeName (NCP.CardTypes))
	then (NCP.ReportWarning "NCP.CreateCardTypeStub" (CONCAT "Redefining NoteCard type: " 
								       TypeName)))
    (NC.AddCardTypeStub TypeName SuperType FullDefinitionFileName FnsAssocList VarsAssocList)
    TypeName))
)
(DECLARE: DONTEVAL@LOAD DOEVAL@COMPILE DONTCOPY COMPILERVARS 

(ADDTOVAR NLAMA )

(ADDTOVAR NLAML )

(ADDTOVAR LAMA NCP.NoteFileProp NCP.CardUserDataProp NCP.LinkType NCP.LinkDisplayMode 
				  NCP.CardSubstance NCP.CardProp NCP.CardTitle 
				  NCP.CardTypeDisplayedInMenu)
)
(PUTPROPS RHTPATCH155 COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (2484 3732 (NCP.ReportError 2494 . 3108) (NCP.ReportWarning 3110 . 3730)) (3733 73047 (
NCP.CreateNoteFile 3743 . 4431) (NCP.CloseNoteFiles 4433 . 5410) (NCP.CheckpointNoteFiles 5412 . 6134)
 (NCP.AbortNoteFiles 6136 . 6852) (NCP.RepairNoteFile 6854 . 7567) (NCP.FileNameFromNoteFile 7569 . 
8107) (NCP.ChangeCardTypeFields 8109 . 8591) (NCP.CardTypeSuper 8593 . 9042) (
NCP.CardTypeLinkDisplayMode 9044 . 9535) (NCP.CardTypeFn 9537 . 10486) (NCP.CardTypeVar 10488 . 11453)
 (NCP.CardTypeDisplayedInMenu 11455 . 12745) (NCP.IsSubTypeOfP 12747 . 13338) (NCP.TextBasedP 13340 . 
13958) (NCP.SketchBasedP 13960 . 14627) (NCP.GraphBasedP 14629 . 15292) (NCP.CreateCard 15294 . 17318)
 (NCP.CreateBrowserCard 17320 . 19231) (NCP.MakeDocument 19233 . 20739) (NCP.MakeLinkIndex 20741 . 
22036) (NCP.OpenCard 22038 . 22638) (NCP.CloseCards 22640 . 23641) (NCP.DisplayCard 23643 . 24408) (
NCP.UndisplayCards 24410 . 25505) (NCP.CacheCards 25507 . 26200) (NCP.UncacheCards 26202 . 27139) (
NCP.CardTitle 27141 . 28092) (NCP.FileCards 28094 . 29316) (NCP.UnfileCards 29318 . 31812) (
NCP.CardParents 31814 . 32506) (NCP.FileBoxChildren 32508 . 33083) (NCP.GetLinks 33085 . 36226) (
NCP.CardProp 36228 . 37552) (NCP.CardAddProp 37554 . 38588) (NCP.CardDelProp 38590 . 39756) (
NCP.CardSubstance 39758 . 41046) (NCP.CardRegion 41048 . 41828) (NCP.CardAddText 41830 . 43061) (
NCP.ChangeLoc 43063 . 44452) (NCP.DeleteCards 44454 . 45293) (NCP.SameCardP 45295 . 45766) (
NCP.CreateLink 45768 . 47113) (NCP.LocalGlobalLink 47115 . 51162) (NCP.GlobalGlobalLink 51164 . 52875)
 (NCP.GlobalLocalLink 52877 . 53265) (NCP.LocalLocalLink 53267 . 53660) (NCP.LinkDesc 53662 . 54340) (
NCP.LinkDisplayMode 54342 . 56015) (NCP.LinkType 56017 . 58053) (NCP.LinkSource 58055 . 58476) (
NCP.LinkDestination 58478 . 58915) (NCP.DeleteLinks 58917 . 59566) (NCP.SameLinkP 59568 . 60039) (
NCP.CreateLinkType 60041 . 60702) (NCP.DeleteLinkType 60704 . 61846) (NCP.RenameLinkType 61848 . 63576
) (NCP.CardDates 63578 . 64542) (NCP.DocumentParameters 64544 . 66557) (NCP.NoteCardsParameters 66559
 . 69289) (NCP.RegisterCardByName 69291 . 69857) (NCP.LookupCardByName 69859 . 70382) (
NCP.UnregisterName 70384 . 70899) (NCP.CardUserDataProp 70901 . 71865) (NCP.NoteFileProp 71867 . 73045
)) (73048 74423 (NCP.CreateCardType 73058 . 73713) (NCP.CreateCardTypeStub 73715 . 74421)))))
STOP