(FILECREATED "16-Feb-87 21:03:29" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH199.;5 28663  

      changes to:  (FNS NC.DoNoteFileOp)
		   (VARS RHTPATCH199COMS)

      previous date: "16-Feb-87 20:58:11" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH199.;4)


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

(PRETTYCOMPRINT RHTPATCH199COMS)

(RPAQQ RHTPATCH199COMS ((* * Fixes bug #436: can pull-across CloseNoteFile menu to avoid user 
			     confirmation of whether to close open cards. New AutoConfirmFlg now 
			     passed to NC.CloseNoteFile and NCP.CloseNoteFiles.)
			  (* * Change to NCPROGINT)
			  (FNS NCP.CloseNoteFiles)
			  (* * Change to NCDATABASE)
			  (FNS NC.CloseNoteFile)
			  (* * Changes to NCINTERFACE)
			  (FNS NC.DoNoteFileOp NC.NoteFileTitleLeftWhenSelectedFn NC.CloseSession)
			  (ADDVARS (NC.NoteFileIconOpenOperations Open Checkpoint Close 
								  Close% w/o% confirm Abort))
			  (* * This is to change the Close menu item in 
			     NC.NoteFileIconOperationsMenuItems. Note that the ADDVARS in 
			     NCINTERFACECOMS needs to be changed.)
			  (P (EDITV NC.NoteFileIconOperationsMenuItems
				    (REPLACE Close WITH (Close NIL "Closes this NoteFile."
							       (SUBITEMS (Close% w/o% confirm NIL 
		     "Close this notefile w/o asking for user confirm before closing open cards.")))))
			     )
			  (* * This is to change the Close% NoteFile menu item in 
			     NC.NoteFileOpsItems. Note that the ADDVARS in NCINTERFACECOMS needs to 
			     be changed.)
			  (P (EDITV NC.NoteFileOpsItems
				    (REPLACE Close% NoteFile WITH
					     (Close% NoteFile (NC.DoNoteFileOp (QUOTE Close% NoteFile)
									       )
							      "Close a notefile."
							      (SUBITEMS (Close% w/o% confirm
									  (NC.DoNoteFileOp
									    (QUOTE 
									      Close% w/o% confirm))
									  
			"Close a notefile w/o asking for user confirm before closing open cards.")))))
			     )
			  (* * This is to change the Close% Session menu item in NC.SessionOpsItems. 
			     Note that the ADDVARS in NCINTERFACECOMS needs to be changed.)
			  (P (EDITV NC.SessionOpsItems (REPLACE Close% Session WITH
								(Close% Session
								  (NC.CloseSession)
								  
							     "Close all currently open NoteFiles"
								  (SUBITEMS (Close% w/o% confirm
									      (NC.CloseSession NIL T)
									      
		"Close all open notefiles w/o asking for user confirm before closing open cards.")))))
			     )
			  (* * Following is just so loading this patch works. Should NOT be 
			     integrated.)
			  (VARS (NC.OpenedNoteFileMenu NIL)
				(NC.ClosedNoteFileMenu NIL)
				(NC.NoteFileOpsMenu NIL)
				(NC.SessionOpsMenu NIL))))
(* * Fixes bug #436: can pull-across CloseNoteFile menu to avoid user confirmation of whether 
to close open cards. New AutoConfirmFlg now passed to NC.CloseNoteFile and NCP.CloseNoteFiles.)

(* * Change to NCPROGINT)

(DEFINEQ

(NCP.CloseNoteFiles
  (LAMBDA (NoteFilesOrT QuietFlg AutoConfirmFlg)             (* rht: "16-Feb-87 16:24")

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



          (* * rht 2/16/87: Now takes AutoConfirmFlg and passes to NC.CloseNoteFile.)


    (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)))))
)
(* * Change to NCDATABASE)

(DEFINEQ

(NC.CloseNoteFile
  (LAMBDA (NoteFile InterestedWindow Don'tCheckOperationInProgressFlg QuietFlg AutoConfirmFlg)
                                                             (* rht: "16-Feb-87 16:22")

          (* * Close a NoteFIle)



          (* * rht 10/23/84: Now gives user option of closing and saving all open cards on the screen.)



          (* * rht 11/8/84: Put RESETLST around NC.CacheTitles call.)



          (* * rht 1/9/85: Clear the NC.UncachingNotCompleted variable when close successfully completes.)



          (* * rht 1/31/85: Added call to checkpoint database. That in turn dumps the next nodeID and next linkID.)



          (* * rht 7/14/85: Replaced the call to reset the main menu with call to NC.ResetMainMenu. Also took out redundant 
	  reset of PSA.Database, since NC.ForceDatabaseClose is doing that.)



          (* * fgh 10/16/85 removed call to CacheTypesAndTitles because uncacheing now done automatically by cache 
	  mechanism.)



          (* * fkr 10/29/85: Now kills caching process from database streamprop.)



          (* * fkr 11/8/85 Updated to handle new NoteFile object and new CardID scheme.)



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



          (* * rht 3/26/86: Now searches for active cards over whole notefile not just among cards up on screen.
	  Uses NC.MapCards.)



          (* * kirk 28Apr86 Now returns NoteFile if successful.)



          (* * fgh 5/2/86 Cleaned up. Ask user to confirm only if there are cards on the screen, not if there are active, but
	  not displayed ones. Added calls to the NC.CloseNoteFileFns before and after the closeing.)



          (* * fgh 5/26/86 Revamp for device vector implementation.)



          (* * kef 7/24/86: Changed the last expression at the end that smashes the NoteFile device out of the NoteFile data 
	  structure. This is so that the Interface will not bomb trying to apply an OPENP function with a NIL Device.)



          (* * kef 8/4/86: Added something to obtain the write lock on the parts of the active NoteCards that deactivating 
	  will release. This is also so that any changes may be written to the server.)



          (* * fgh 8/31/86 Reimplemented changes in system made since 5/23/86 conversion. Reimplemented changes include: 
	  (* * fgh 6/4/86 Fixed so that shrunken cards are counted as open when asking for confirmation when there are open 
	  cards on screen.) (* * fgh 6/13/86 Now checks for card operations in progress and kills them if necessary.) 
	  (* * fgh 6/25/86 Added NC.ProtectedNoteFileOperation macro call. Added Don'tCheckOperationInProgressFlg args.) 
	  (* * rht 7/4/86: Added check for readonly notefile.) (* * rht 7/13/86: Added QuietFlg arg. Note that this will 
	  cause open cards on the screen to be closed and saved without asking user for confirmation.) 
	  (* * rpr 11/13/86: After closing active cards, checks to see if any special cards were made active and closes 
	  them.))



          (* * pmi 12/22/86 Made test for open notefile consistent with other NoteFile operations (ie. Abort Checkpoint,))



          (* * rht 2/16/87: Added AutoConfirmFlg argument to prevent user having to confirm whether to close and save open 
	  cards. Note that QuietFlg is stronger than AutoConfirmFlg in that other messages are suppressed as well.)


    (DECLARE (GLOBALVARS NC.MsgDelay NC.CloseNoteFileFns))
    (if (NC.ReadOnlyNoteFileP NoteFile)
	then (NC.AbortSession NoteFile InterestedWindow)
      else
       (ALLOW.BUTTON.EVENTS)
       (PROG ((FullFileName (fetch (NoteFile FullFileName) of NoteFile))
		CardTotal ActiveCards ReturnValue (OperationMsg ""))
	       (OR InterestedWindow (if (type? MENU (fetch (NoteFile Menu) of NoteFile))
					  then (SETQ InterestedWindow (WFROMMENU
						     (fetch (NoteFile Menu) of NoteFile)))))

          (* * Make sure NF is open)


	       (if (NULL (ERSETQ (SETQ ReturnValue (NC.NoteFileOpenP NoteFile))))
		   then (SETQ ReturnValue (QUOTE OpenPFailed)))
	       (if (NULL ReturnValue)
		   then 

          (* * NoteFile is not open.)


			  (NC.PrintMsg InterestedWindow T "Can't close a closed notefile."
					 (CHARACTER 13))
			  (DISMISS NC.MsgDelay)
			  (NC.ClearMsg InterestedWindow T)
			  (RETURN NIL)
		 elseif (NOT (type? NoteFile ReturnValue))
		   then 

          (* * Error return from NoteFileOpenPFn)


			  (if (NULL (ERSETQ (NC.ReportError NIL (CONCAT "OpenP test on " 
										  FullFileName 
										"failed because "
										  ReturnValue
										  (CHARACTER 13)
										  
							"OK to continue Close. ↑ to abort Close."))))
			      then (RETURN ReturnValue)))

          (* * Check to see if this NoteFile is busy doing something else)


	       (if (AND (NULL Don'tCheckOperationInProgressFlg)
			    (PROCESSP (NC.NoteFileProp NoteFile (QUOTE ProcessInProgress))))
		   then (NC.PrintOperationInProgressMsg InterestedWindow (QUOTE Close% NoteFile)
							    (NC.NoteFileProp NoteFile (QUOTE
										 OperationInProgress))
							    )
			  (RETURN NIL))

          (* * Do the rest under an operation in progress lock.)


	       (RETURN
		 (NC.ProtectedNoteFileOperation
		   NoteFile Close% NoteFile
		   (PROG NIL
		           (RESETSAVE NIL (BQUOTE (NC.ClearMsg , InterestedWindow T)))

          (* * Delete the types and titles caching process if still alive. Have to do it now in order to make checking 
	  operations that follow suitably efficient. Note its a bit too early since we can still cancel this close.
	  But any harm done is loss of speed if NoteFile remains open when close iss cancelled.)


		           (DEL.PROCESS (fetch (NoteFile CachingProcess) of NoteFile))

          (* * See if any cards have operations in progress. If so, kill them after confirming with user.)


		           (OR QuietFlg (NC.PrintMsg InterestedWindow T (OR OperationMsg "")
							 
						   "Checking for card operations in progress ..."
							 (CHARACTER 13)))
		           (if (EQ (QUOTE ABORT)
				       (NC.CardOperationsInProgress NoteFile T))
			       then (RETURN NIL))
		           (NC.ClearMsg InterestedWindow NIL)

          (* * If NULL QuietFlg then look for cards on the screen. If there are active cards ask the user if they still want 
	  to close. When there's a non-NIL QuietFlg we just close the active cards.)


		           (if
			     (AND (NULL QuietFlg)
				    (NULL AutoConfirmFlg)
				    (for Window in (OPENWINDOWS)
				       thereis
					(LET (Card)
					     (AND (SETQ Card
						      (OR (NC.CardFromWindow Window)
							    (AND (WINDOWP (WINDOWPROP
										Window
										(QUOTE ICONFOR)))
								   (NC.CardFromWindow
								     (WINDOWPROP Window
										   (QUOTE ICONFOR)))
								   )))
						    (NC.SameNoteFileP NoteFile (fetch
									  (Card NoteFile)
										    of Card)))))
				    (NULL (NC.AskYesOrNo (CONCAT 
					"There are still cards on the screen from this NoteFile "
								       FullFileName "." (CHARACTER
									 13)
								       
								  "Want to close and save them? ")
							     " -- "
							     (QUOTE Yes)
							     NIL InterestedWindow NIL NIL)))
			       then (RETURN NIL))

          (* * Run through CloseNoteFileFns with param of BEFORE. Exit if any returns DON'T)


		           (if (for Function in NC.CloseNoteFileFns
				    thereis (OR (EQ Function (QUOTE DON'T))
						    (EQ (QUOTE DON'T)
							  (APPLY* Function NoteFile (QUOTE BEFORE)
								    ))))
			       then (RETURN NIL))

          (* * Close all the active cards)


		           (OR QuietFlg (NC.PrintMsg InterestedWindow T (OR OperationMsg "")
							 "Checking for active cards ..."
							 (CHARACTER 13)))
		           (if (SETQ ActiveCards (NC.MapCards NoteFile (FUNCTION (LAMBDA (Card)
								      Card))
								  (FUNCTION NC.ActiveCardP)))
			       then (if (NULL QuietFlg)
					  then (NC.PrintMsg InterestedWindow T 
							   "Closing and saving active cards ... "))
				      (RESETLST (RESETSAVE NC.ForceSourcesFlg NIL)
						  (RESETSAVE NC.ForceFilingFlg NIL)
						  (RESETSAVE NC.ForceTitlesFlg NIL)
						  (NC.CloseListOfActiveCards ActiveCards 
									       InterestedWindow 
									       QuietFlg)
						  (NC.CloseListOfActiveCards (for Card
										  in (
									     NC.FetchSpecialCards
											 NoteFile)
										  when
										   (NC.ActiveCardP
										     Card)
										  collect Card)
									       InterestedWindow 
									       QuietFlg))
				      (OR QuietFlg (NC.PrintMsg InterestedWindow NIL "Done."
								    (CHARACTER 13))))

          (* * Checkpoint the NoteFile.)


		           (OR QuietFlg (NC.PrintMsg InterestedWindow T "Closing Notefile ... "
							 (CHARACTER 13)))
		           (if (NULL (CAR (ERSETQ (SETQ ReturnValue
							    (NC.CheckpointNoteFile NoteFile 
										     QuietFlg T T T 
										 InterestedWindow 
										     OperationMsg)))))
			       then (SETQ ReturnValue (QUOTE CheckpointFailed)))

          (* * Process error returns from in NC.CheckpointNoteFile)


		           (if (NOT (type? NoteFile ReturnValue))
			       then (if (NULL (ERSETQ (NC.ReportError NIL
										(CONCAT
										  
									"Checkpoint of NoteFile "
										  FullFileName 
									       " failed because "
										  ReturnValue "."
										  (CHARACTER 13)
										  
							"OK to continue Close. ↑ to abort Close."))))
					  then (RETURN ReturnValue)))

          (* * Close the file.)


		           (if (NULL (CAR (ERSETQ (SETQ ReturnValue
							    (APPLY* (fetch (NoteFile 
										  CloseNoteFileFn)
									 of NoteFile)
								      NoteFile InterestedWindow)))))
			       then (SETQ ReturnValue (QUOTE CloseFailed)))

          (* * Process error returns from the close.)


		           (if (NOT (type? NoteFile ReturnValue))
			       then (SELECTQ
					ReturnValue
					(NoteFileNotOpen
					  (if (NULL (ERSETQ (NC.ReportError
								    NIL
								    (CONCAT "NoteFile" FullFileName 
									      " is not open."
									      (CHARACTER 13)
									      
							"OK to continue Close. ↑ to abort Close."))))
					      then (RETURN ReturnValue)))
					(PROGN (ERSETQ (NC.ReportError NIL
									     (CONCAT 
									     "Close of NoteFile "
										       FullFileName 
									       " failed because "
										       ReturnValue 
										       "."
										       (CHARACTER
											 13))))
						 (RETURN ReturnValue))))

          (* * Run through CloseNoteFileFns with param of AFTER. Stop if any returns DON'T)


		           (for Function in NC.CloseNoteFileFns
			      thereis (EQ (QUOTE DON'T)
					      (APPLY* Function NoteFile (QUOTE AFTER))))

          (* * Reset the interface and notify the user.)


		           (NC.ResetNoteFileInterface NoteFile)
		           (OR QuietFlg (NC.PrintMsg InterestedWindow T FullFileName " closed."))

          (* * * Cleanup a bit.)

                                                             (* Clean off the card cache's)
		           (ADD.PROCESS (LIST (FUNCTION NC.CleanupCardObjects)
						  (fetch (NoteFile HashArray) of NoteFile)))
                                                             (* Clean off the NoteFile object to remove any 
							     circularities.)
		           (create NoteFile smashing NoteFile Stream ← NIL UID ←(fetch
							   (NoteFile UID) of NoteFile)
							 FullFileName ← FullFileName Menu ←(fetch
							   (NoteFile Menu) of NoteFile)
							 NoteFileDevice ←(fetch (NoteFile 
										   NoteFileDevice)
									    of NoteFile))

          (* * Return the NF)


		           (RETURN NoteFile))))))))
)
(* * Changes to NCINTERFACE)

(DEFINEQ

(NC.DoNoteFileOp
  (LAMBDA (Op)                                               (* rht: "16-Feb-87 20:59")

          (* * Do a NoteFile op chosen from NC icon menu)



          (* * rht 7/2/86: Now calls NC.AbortSession with NC.NoteCardsIconWindow arg.)



          (* * rht 7/5/86: Added Read-only% Open entry.)



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



          (* * pmi 12/4/86: Added NC.NoteCardsIconWindow argument to calls to NC.ListOfNoteFilesMenu for "Delete" and 
"Rename" operations)



          (* * rht 2/11/87: Now handles case when Op has unexpected value.)



          (* * rht 2/16/87: Added Close% w/o% confirm case.)


    (DECLARE (GLOBALVARS NC.NoteCardsIconWindow))
    (SELECTQ Op
	       (Open% NoteFile (LET ((NoteFile (NC.ListOfNoteFilesMenu T NIL NC.NoteCardsIconWindow
									 (QUOTE Open% NoteFile))))
				    (if (NULL NoteFile)
					then NIL
				      else (if (EQ NoteFile (QUOTE NEW))
						 then (SETQ NoteFile NIL))
					     (NC.OpenDatabaseFile NoteFile NIL NIL NIL NIL NIL NIL 
								    NIL NIL NIL 
								    NC.NoteCardsIconWindow))))
	       (Read-only% Open (LET ((NoteFile (NC.ListOfNoteFilesMenu T NIL 
									  NC.NoteCardsIconWindow
									  (QUOTE Open% NoteFile))))
				     (if (NULL NoteFile)
					 then NIL
				       else (if (EQ NoteFile (QUOTE NEW))
						  then (SETQ NoteFile NIL))
					      (NC.OpenDatabaseFile NoteFile (QUOTE INPUT)
								     NIL NIL NIL NIL NIL NIL NIL NIL 
								     NC.NoteCardsIconWindow))))
	       (Checkpoint% NoteFile (LET ((NoteFile (NC.ListOfNoteFilesMenu NIL T 
									   NC.NoteCardsIconWindow
									       (QUOTE 
									     Checkpoint% NoteFile))))
				          (if NoteFile
					      then (NC.CheckpointDatabase NoteFile NIL NIL NIL 
									      NIL 
									   NC.NoteCardsIconWindow))))
	       (Close% NoteFile (LET ((NoteFile (NC.ListOfNoteFilesMenu NIL T 
									  NC.NoteCardsIconWindow
									  (QUOTE Close% NoteFile))))
				     (if NoteFile
					 then (NC.CloseNoteFile NoteFile NC.NoteCardsIconWindow)))
				)
	       (Close% w/o% confirm (LET ((NoteFile (NC.ListOfNoteFilesMenu NIL T 
									   NC.NoteCardsIconWindow
									      (QUOTE 
										  Close% NoteFile))))
				         (if NoteFile
					     then (NC.CloseNoteFile NoteFile 
									NC.NoteCardsIconWindow NIL 
									NIL T))))
	       (Abort% NoteFile (LET ((NoteFile (NC.ListOfNoteFilesMenu NIL T 
									  NC.NoteCardsIconWindow
									  (QUOTE Abort% NoteFile))))
				     (if NoteFile
					 then (NC.AbortSession NoteFile NC.NoteCardsIconWindow))))
	       (Compact% NoteFile (LET ((NoteFile (NC.ListOfNoteFilesMenu T NIL 
									   NC.NoteCardsIconWindow
									    (QUOTE 
										Compact% NoteFile))))
				       (if (NULL NoteFile)
					   then NIL
					 else (if (EQ NoteFile (QUOTE NEW))
						    then (SETQ NoteFile NIL))
						(NC.CompactNoteFile NoteFile NIL NIL 
								      NC.NoteCardsIconWindow))))
	       (Compact% In% Place (LET ((NoteFile (NC.ListOfNoteFilesMenu T NIL 
									   NC.NoteCardsIconWindow
									     (QUOTE 
										Compact% NoteFile))))
				        (if (NULL NoteFile)
					    then NIL
					  else (if (EQ NoteFile (QUOTE NEW))
						     then (SETQ NoteFile NIL))
						 (NC.CompactNoteFile NoteFile NIL T 
								       NC.NoteCardsIconWindow))))
	       (Inspect&Repair% NoteFile (LET ((NoteFile (NC.ListOfNoteFilesMenu T NIL 
									   NC.NoteCardsIconWindow
										   (QUOTE 
									 Inspect&Repair% NoteFile))))
					      (if (NULL NoteFile)
						  then NIL
						else (if (EQ NoteFile (QUOTE NEW))
							   then (SETQ NoteFile NIL))
						       (NC.InspectAndRepairNoteFile NoteFile NIL 
									   NC.NoteCardsIconWindow))))
	       (Read% Substances (LET ((NoteFile (NC.ListOfNoteFilesMenu T NIL 
									   NC.NoteCardsIconWindow
									   (QUOTE 
									 Inspect&Repair% NoteFile))))
				      (if (NULL NoteFile)
					  then NIL
					else (if (EQ NoteFile (QUOTE NEW))
						   then (SETQ NoteFile NIL))
					       (NC.InspectAndRepairNoteFile NoteFile T 
									   NC.NoteCardsIconWindow))))
	       (Copy% NoteFile (LET ((NoteFile (NC.ListOfNoteFilesMenu T (QUOTE CLOSED)
									 NC.NoteCardsIconWindow
									 (QUOTE Copy% NoteFile))))
				    (if (NULL NoteFile)
					then NIL
				      else (if (EQ NoteFile (QUOTE NEW))
						 then (SETQ NoteFile NIL))
					     (NC.CopyNoteFile NoteFile NIL NC.NoteCardsIconWindow)))
			       )
	       (Rename% NoteFile (LET ((NoteFile (NC.ListOfNoteFilesMenu T (QUOTE CLOSED)
									   NC.NoteCardsIconWindow
									   (QUOTE Rename% NoteFile))
						 ))
				      (if (NULL NoteFile)
					  then NIL
					else (if (EQ NoteFile (QUOTE NEW))
						   then (SETQ NoteFile NIL))
					       (NC.RenameNoteFile NoteFile NIL 
								    NC.NoteCardsIconWindow))))
	       (Delete% NoteFile (LET ((NoteFile (NC.ListOfNoteFilesMenu T (QUOTE CLOSED)
									   NC.NoteCardsIconWindow
									   (QUOTE Delete% NoteFile))
						 ))
				      (if (NULL NoteFile)
					  then NIL
					else (if (EQ NoteFile (QUOTE NEW))
						   then (SETQ NoteFile NIL))
					       (NC.DeleteDatabaseFile NoteFile 
									NC.NoteCardsIconWindow))))
	       (Create% NoteFile (NC.CreateDatabaseFile NIL NIL NIL NIL NIL NIL 
							  NC.NoteCardsIconWindow))
	       (LET ((NoteFile (NC.ListOfNoteFilesMenu NIL T NC.NoteCardsIconWindow (QUOTE 
										  Close% NoteFile))))
		    (if NoteFile
			then (APPLY* Op NoteFile NC.NoteCardsIconWindow))))))

(NC.NoteFileTitleLeftWhenSelectedFn
  (LAMBDA (Item Menu Button)                                 (* rht: "16-Feb-87 16:56")

          (* * WhenSelectedFn for the menus NC.OpenedNoteFileMenu and NC.ClosedNoteFileMenu. These operations used to be 
	  performed by NC.NoteFileOperations. Provides faster Left-button title bar menu on NoteFile icons.)



          (* * rht 2/11/87: Now handles possibly extra unanticipated menu items.)



          (* * rht 2/11/87: Removed useless call to DEFAULTWHENSELECTEDFN.)



          (* * rht 2/16/87: Added Close% cards% w/o% confirm case.)


    (DECLARE (GLOBALVARS NC.NoteFilesHashArray NC.NoteFileIconCloseOperations 
			     NC.NoteFileIconOpenOperations NC.MsgDelay))
    (LET ((NoteFile (GETMENUPROP Menu (QUOTE NoteFile)))
	  (Operation (CAR Item))
	  NoteFileMenuWindow)
         (SETQ NoteFileMenuWindow (WFROMMENU (fetch (NoteFile Menu) of NoteFile)))
         (WINDOWPROP NoteFileMenuWindow (QUOTE BusyOperation)
		       Operation)
         (COND
	   ((AND (NC.NoteFileOpenP NoteFile)
		   (NOT (FMEMB Operation NC.NoteFileIconOpenOperations)))
	     (NC.PrintMsg NoteFileMenuWindow T "Can't " Operation " an open notefile."
			    (CHARACTER 13))
	     (DISMISS NC.MsgDelay)
	     (NC.ClearMsg NoteFileMenuWindow T))
	   ((AND (NOT (NC.NoteFileOpenP NoteFile))
		   (NOT (FMEMB (CAR Item)
				   NC.NoteFileIconCloseOperations)))
	     (NC.PrintMsg NoteFileMenuWindow T "Can't " Operation " a closed notefile."
			    (CHARACTER 13))
	     (DISMISS NC.MsgDelay)
	     (NC.ClearMsg NoteFileMenuWindow T))
	   (T (SELECTQ Operation
			 (Open (NC.OpenNoteFile NoteFile NC.NoteFilesHashArray NIL NIL NIL NIL NIL 
						  NIL NIL NoteFileMenuWindow))
			 (Read-only% Open (NC.OpenNoteFile NoteFile NC.NoteFilesHashArray NIL NIL 
							     NIL NIL NIL NIL NIL NoteFileMenuWindow 
							     NIL NIL NIL NIL T))
			 (Checkpoint (NC.CheckpointNoteFile NoteFile NIL NIL NIL NIL 
							      NoteFileMenuWindow))
			 (Close (NC.CloseNoteFile NoteFile NoteFileMenuWindow))
			 (Close% w/o% confirm (NC.CloseNoteFile NoteFile NoteFileMenuWindow NIL NIL 
								  T))
			 (Abort (NC.AbortSession NoteFile NoteFileMenuWindow))
			 (Compact (NC.CompactNoteFile NoteFile NIL NIL NoteFileMenuWindow))
			 (Compact% To% Target% File (NC.CompactNoteFile NoteFile NIL NIL 
									  NoteFileMenuWindow))
			 (Compact% In% Place (NC.CompactNoteFile NoteFile NIL T NoteFileMenuWindow))
			 (Inspect&Repair (NC.InspectAndRepairNoteFile NoteFile NIL 
									NoteFileMenuWindow))
			 (Read% Substances (NC.InspectAndRepairNoteFile NoteFile T 
									  NoteFileMenuWindow))
			 (Copy (NC.CopyNoteFile NoteFile NIL NoteFileMenuWindow))
			 (Rename (NC.RenameNoteFile NoteFile))
			 (Delete (NC.DeleteDatabaseFile NoteFile NoteFileMenuWindow))
			 (APPLY* (CADR Item)
				   NoteFile NoteFileMenuWindow)))))))

(NC.CloseSession
  (LAMBDA (DeleteChangesFlg AutoConfirmFlg)                  (* rht: "16-Feb-87 17:14")

          (* * Checkpoint all open NoteFiles)



          (* * rht 2/16/87: Now accepts AutoConfirmFlg and passes to NC.AbortSession and NC.CloseNoteFile.)


    (MAPHASH NC.NoteFilesHashArray (FUNCTION (LAMBDA (Value Key)
		   (AND (type? NoteFile Value)
			  (if (AND (STREAMP (SETQ Stream (fetch (NoteFile Stream)
								    of Value)))
				       (OPENP Stream))
			      then (if DeleteChangesFlg
					 then (NC.AbortSession Value NIL AutoConfirmFlg)
				       else (NC.CloseNoteFile Value NIL NIL NIL AutoConfirmFlg))))
		   )))
    (NC.PrintMsg NIL T "Done closing all NoteFiles.")))
)

(ADDTOVAR NC.NoteFileIconOpenOperations Open Checkpoint Close Close% w/o% confirm Abort)
(* * This is to change the Close menu item in NC.NoteFileIconOperationsMenuItems. Note that 
the ADDVARS in NCINTERFACECOMS needs to be changed.)

(EDITV NC.NoteFileIconOperationsMenuItems (REPLACE Close WITH (Close NIL "Closes this NoteFile."
								     (SUBITEMS (Close% w/o% confirm
										 NIL 
		     "Close this notefile w/o asking for user confirm before closing open cards.")))))
(* * This is to change the Close% NoteFile menu item in NC.NoteFileOpsItems. Note that the 
ADDVARS in NCINTERFACECOMS needs to be changed.)

(EDITV NC.NoteFileOpsItems (REPLACE Close% NoteFile WITH (Close% NoteFile
				      (NC.DoNoteFileOp (QUOTE Close% NoteFile))
				      "Close a notefile."
				      (SUBITEMS (Close% w/o% confirm (NC.DoNoteFileOp (QUOTE 
									      Close% w/o% confirm))
								     
			"Close a notefile w/o asking for user confirm before closing open cards.")))))
(* * This is to change the Close% Session menu item in NC.SessionOpsItems. Note that the 
ADDVARS in NCINTERFACECOMS needs to be changed.)

(EDITV NC.SessionOpsItems (REPLACE Close% Session WITH (Close% Session (NC.CloseSession)
								       
							     "Close all currently open NoteFiles"
								       (SUBITEMS (Close% w/o% confirm
										   (NC.CloseSession
										     NIL T)
										   
		"Close all open notefiles w/o asking for user confirm before closing open cards.")))))
(* * Following is just so loading this patch works. Should NOT be integrated.)


(RPAQQ NC.OpenedNoteFileMenu NIL)

(RPAQQ NC.ClosedNoteFileMenu NIL)

(RPAQQ NC.NoteFileOpsMenu NIL)

(RPAQQ NC.SessionOpsMenu NIL)
(PUTPROPS RHTPATCH199 COPYRIGHT ("Xerox Corporation" 1987))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (2914 3996 (NCP.CloseNoteFiles 2924 . 3994)) (4030 16803 (NC.CloseNoteFile 4040 . 16801)
) (16839 26853 (NC.DoNoteFileOp 16849 . 22996) (NC.NoteFileTitleLeftWhenSelectedFn 22998 . 26062) (
NC.CloseSession 26064 . 26851)))))
STOP