(FILECREATED "20-Nov-86 00:15:02" {QV}<NOTECARDS>1.3K>NEXT>KIRKPATCH032.;2 4479   

      previous date: "18-Nov-86 15:32:28" {QV}<NOTECARDS>1.3K>NEXT>KIRKPATCH032.;1)


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

(PRETTYCOMPRINT KIRKPATCH032COMS)

(RPAQQ KIRKPATCH032COMS ((* * change to NCDATABASE to fix Lyric problem)
			   (FNS NC.AbortSession)))
(* * change to NCDATABASE to fix Lyric problem)

(DEFINEQ

(NC.AbortSession
  (LAMBDA (NoteFile InterestedWindow Don'tConfirmFlg QuietFlg)
                                                             (* kirk: "18-Nov-86 15:26")

          (* * Kill the current notecards session. Work lost since last checkpoint.)



          (* * 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 & rht 10/16/85 Update with new cacheing mechanism.)



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



          (* * kirk 20Jan86 Added Don'tCloseFlg to leave NoteFile open after done deleting changes.)



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



          (* * rht 7/2/86: No longer bugs you if no changes were made since last checkpoint. Removed Don'tCloseFlg arg and 
	  added InterestedWindow arg.)



          (* * rht 7/6/86: Now clears InterestedWindow of final truncating message.)



          (* * rht 7/13/86: Added Don'tConfirmFlg and QuietFlg args. Note that Don'tConfirmFlg non-nil stops questioning of 
	  user as to losing all changes.)



          (* * kirk 11/17/86 Changed call on SETFILEINFO to pass stream instead of filename.)


    (LET ((Stream (fetch (NoteFile Stream) of NoteFile))
	  (FullFileName (fetch (NoteFile FullFileName) of NoteFile))
	  (LastChkptPtr (fetch (NoteFile CheckptPtr) of NoteFile))
	  EndPtr CardTotal NewBytes)
         (if (AND (STREAMP Stream)
		      (OPENP Stream))
	     then (OR InterestedWindow (SETQ InterestedWindow (WFROMMENU (fetch
										   (NoteFile Menu)
										    of NoteFile))))
		    (SETQ EndPtr (GETEOFPTR Stream))
		    (SETQ NewBytes (IDIFFERENCE EndPtr LastChkptPtr))
		    (if (OR (ZEROP NewBytes)
				Don'tConfirmFlg
				(NC.AskYesOrNo (CONCAT "Do you wish to lose all changes since"
							   (CHARACTER 13)
							   "the last checkpoint (" NewBytes 
							   " bytes) of "
							   FullFileName)
						 "--" "Yes" NIL InterestedWindow NIL T))
			then
			 (LET ((CardNumber 0)
			       (CardTotal (fetch (NoteFile HashArraySize) of NoteFile)))
			      (NC.MapCards NoteFile
					   (FUNCTION (LAMBDA (Card)
					       (LET (Win)
						    (SETQ CardNumber (ADD1 CardNumber))
						    (OR QuietFlg (COND
							    ((ZEROP (IREMAINDER CardNumber 100))
							      (NC.PrintMsg InterestedWindow T 
								"Quitting from active cards ... "
									     (CHARACTER 13)
									     
									"Processing item number "
									     CardNumber " out of " 
									     CardTotal "."
									     (CHARACTER 13)))))
						    (COND
						      ((NC.ActiveCardP Card)
							(SETQ Win (NC.FetchWindow Card))
							(NC.AbortCard Card QuietFlg)
							(COND
							  (Win (bind (Process ←
										(WINDOWPROP
										  Win
										  (QUOTE PROCESS)))
								  until (OR (NULL Process)
										(PROCESS.FINISHEDP
										  Process))
								  do (BLOCK))
							       (CLOSEW Win))))))))))
			 (COND
			   ((LESSP LastChkptPtr EndPtr)
			     (OR QuietFlg (NC.PrintMsg InterestedWindow T "Truncating file " 
							   FullFileName " ..."))
			     (COND
			       ((NOT (SETFILEINFO Stream (QUOTE LENGTH)
						      LastChkptPtr))
				 (NC.PrintMsg InterestedWindow NIL "Couldn't truncate " 
						FullFileName "." (CHARACTER 13))))))
			 (NC.ResetNoteFileInterface NoteFile)
			 (NC.ForceDatabaseClose NoteFile))
		    (NC.ClearMsg InterestedWindow T)
	   else (NC.PrintMsg InterestedWindow T FullFileName " is not an open NoteFile!!!"
				 (CHARACTER 13))))))
)
(PUTPROPS KIRKPATCH032 COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (439 4396 (NC.AbortSession 449 . 4394)))))
STOP