(FILECREATED " 4-Dec-86 11:50:59" {QV}<NOTECARDS>1.3K>NEXT>PMIPATCH003.;3 6739   

      changes to:  (FNS NC.CheckpointNoteFile)
		   (VARS PMIPATCH003COMS)

      previous date: " 3-Dec-86 17:09:32" {QV}<NOTECARDS>1.3K>NEXT>PMIPATCH003.;1)


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

(PRETTYCOMPRINT PMIPATCH003COMS)

(RPAQQ PMIPATCH003COMS ((* * Fixes bug #278: Checkpointing a closed NoteFile no longer causes a 
			     break.)
			  (* * Change to NCDATABASE)
			  (FNS NC.CheckpointNoteFile)))
(* * Fixes bug #278: Checkpointing a closed NoteFile no longer causes a break.)

(* * Change to NCDATABASE)

(DEFINEQ

(NC.CheckpointNoteFile
  (LAMBDA (NoteFile QuietFlg Don'tSaveDirtyCardsFlg Don'tCheckOperationInProgressFlg 
		    Don'tCheckCardOperationsInProgressFlg InterestedWindow OperationMsg)
                                                             (* pmi: " 4-Dec-86 11:50")

          (* * Checkpoint a notefile by call the device specific checkpoint fn.)



          (* * fgh 5/26/86 First created.)



          (* * fgh 9/1/86 Updated with with changes made to checkpinting since 5/23/86. Reimplemented changes include: 
	  (* * fgh 6/4/86 Added Don'tSaveDirtyCardsFlg to prevent double passes through active cards at close time) 
	  (* * fgh 6/13/86 Changed printouts to NF menu. Added check for operations in progress.) (* * fgh 6/25/86 Put in 
	  contention lock and NC.ProtectedNoteFileOperation Added Don'tCheckOperationInProgressFlg 
	  Don'tCheckCardOperationsInProgressFlg & InterestedWindow args.) (* * rht 7/4/86: Added check for readonly 
	  notefile.) (* * rht 7/16/86: Now passes QuietFlg arg down to NC.SaveDirtyCards.))



          (* * pmi 12/3/86 Added check for open NoteFile before attempting Checkpoint (Code stolen from NC.CloseNoteFile))


    (PROG (ReturnValue)
	    (OR InterestedWindow (SETQ InterestedWindow (WFROMMENU (fetch (NoteFile Menu)
									    of NoteFile))))

          (* * Make sure NF is open)


	    (if (NULL (ERSETQ (SETQ ReturnValue (APPLY* (fetch (NoteFile NoteFileOpenPFn)
								     of NoteFile)
								  NoteFile))))
		then (SETQ ReturnValue (QUOTE OpenPFailed)))
	    (if (NULL ReturnValue)
		then 

          (* * NoteFile is not open.)


		       (NC.PrintMsg InterestedWindow T (fetch (NoteFile FullFileName)
							    of NoteFile)
				      " is not an open NoteFile!!!"
				      (CHARACTER 13))
		       (RETURN NIL)
	      elseif (NOT (type? NoteFile ReturnValue))
		then 

          (* * Error return from NoteFileOpenPFn)


		       (if (NULL (ERSETQ (NC.ReportError NIL (CONCAT "OpenP test on "
									       (fetch (NoteFile
											  
										     FullFileName)
										  of NoteFile)
									       "failed because " 
									       ReturnValue
									       (CHARACTER 13)
									       
					      "OK to continue Checkpoint. ↑ to abort Checkpoint."))))
			   then (RETURN ReturnValue)))
	    (SETQ OperationMsg (CONCAT (OR OperationMsg "")
					   "Checkpointing "
					   (fetch (NoteFile FullFileName) of NoteFile)
					   (CHARACTER 13)))
	    (if (NC.CheckForNotReadOnly NoteFile InterestedWindow "Can't checkpoint ")
		then (if (AND (NULL Don'tCheckOperationInProgressFlg)
				    (PROCESSP (NC.NoteFileProp NoteFile (QUOTE 
										ProcessInProgress))))
			   then 

          (* * Another operation is in progress on this NF.)


				  (NC.PrintOperationInProgressMsg InterestedWindow (QUOTE 
									     Checkpoint% NoteFile)
								    (NC.NoteFileProp NoteFile
										       (QUOTE
											 
									      OperationInProgress)))
			 else

          (* * Okay checkpoint under a contention lock.)


			  (RETURN (NC.ProtectedNoteFileOperation
				      NoteFile Checkpoint% NoteFile
				      (OR QuietFlg (RESETSAVE NIL (BQUOTE (NC.ClearMsg , 
										 InterestedWindow T)))
					    )
				      (if (OR Don'tCheckCardOperationsInProgressFlg
						  (PROGN (OR QuietFlg (NC.PrintMsg
								   InterestedWindow T OperationMsg 
						      "Checking for card operations in progress."
								   (CHARACTER 13)))
							   (NULL (SETQ OpsInProgress
								     (NC.CardOperationsInProgress
								       NoteFile))))
						  (NC.AskYesOrNo (CONCAT 
							 "There are card operations in progress."
									     (CHARACTER 13)
									     
								 "Do you want to terminate them?"
									     (CHARACTER 13))
								   "-->"
								   (QUOTE Yes)
								   T InterestedWindow))
					  then 

          (* * If appropriate, msg the user.)


						 (OR QuietFlg (NC.PrintMsg InterestedWindow T 
									"Checkpointing notefile "
									       (fetch (NoteFile
											  
										     FullFileName)
										  of NoteFile)
									       " ..."
									       (CHARACTER 13)))

          (* * Save the dirty cards on the screen if necessary.)


						 (if (NULL Don'tSaveDirtyCardsFlg)
						     then (NC.SaveDirtyCards NoteFile T 
										 InterestedWindow 
										 OperationMsg 
										 QuietFlg))
                                                             (* Put out the new ChkptPtr to the file.)

          (* * Call the device specific checkpoint fn.)


						 (if (NULL (ERSETQ
								 (SETQ ReturnValue
								   (APPLY* (fetch (NoteFile
											
									     CheckpointNoteFileFn)
										of NoteFile)
									     NoteFile 
									     InterestedWindow 
									     OperationMsg QuietFlg))))
						     then (SETQ ReturnValue (QUOTE 
										 CheckpointFailed)))

          (* * Process the error returns.)


						 (if (type? NoteFile ReturnValue)
						     then 

          (* * Successful return.)


							    (OR QuietFlg (NC.PrintMsg
								    InterestedWindow T
								    (OR OperationMsg "")
								    " Checkpoint done."
								    (CHARACTER 13)))
							    NoteFile
						   else 

          (* * Error return.)


							  (ERSETQ
							    (NC.ReportError
							      NIL
							      (CONCAT "Checkpoint failed for "
									(fetch (NoteFile 
										     FullFileName)
									   of NoteFile)
									" because " ReturnValue ".")))
							  ReturnValue)))))))))
)
(PUTPROPS PMIPATCH003 COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (654 6657 (NC.CheckpointNoteFile 664 . 6655)))))
STOP