(FILECREATED " 5-Nov-85 20:04:45" {QV}<NOTECARDS>1.3K>RHTPATCH004.;1 3433   

      changes to:  (VARS RHTPATCH004COMS))


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

(PRETTYCOMPRINT RHTPATCH004COMS)

(RPAQQ RHTPATCH004COMS ((* * Please be careful integrating this function. I believe there may have 
			   been changes to it in 1.3k since the enclosed version.)
			(FNS NC.AbortSession)))
(* * Please be careful integrating this function. I believe there may have been changes to it 
in 1.3k since the enclosed version.)

(DEFINEQ

(NC.AbortSession
  (LAMBDA (Stream)                                           (* rht: " 5-Nov-85 19:56")

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



          (* * rht 11/5/85: Added Stream arg and changed PSA.Database to Stream throughout. Now bails out if Stream not open.)


    (PROG (FullFileName LastChkptPtr EndPtr CardTotal)
          (OR Stream (SETQ Stream PSA.Database))
          (if (OR (NULL Stream)
		  (NOT (OPENP Stream)))
	      then (NC.PrintMsg NIL T "There is no open NoteFile!!!" (CHARACTER 13))
		   (RETURN NIL))
          (SETQ FullFileName (FULLNAME Stream))
          (SETFILEPTR Stream 8)
          (SETQ LastChkptPtr (NC.GetPtr Stream))
          (SETQ EndPtr (GETEOFPTR Stream))
          (NC.PrintMsg NIL T "Aborting will lose work since the last checkpoint i.e., the last "
		       (IDIFFERENCE EndPtr LastChkptPtr)
		       " bytes of " FullFileName (CHARACTER 13))
          (if (NC.YesP (NC.AskUser "Want to abort anyway? " "--" "Yes" NIL NIL NIL T T))
	      then (for CardNumber from 1 to (SETQ CardTotal (SUB1 (SUBATOM (NC.GetNewID Stream T)
									    3)))
		      bind ID Win
		      do (BLOCK)
			 (if (ZEROP (IREMAINDER CardNumber 10))
			     then (NC.PrintMsg NIL T "Quitting from active cards ... " (CHARACTER
						 13)
					       "Processing item number " CardNumber " out of " 
					       CardTotal "." (CHARACTER 13)))
			 (if (NC.ActiveCardP (SETQ ID (NC.IDFromNumber CardNumber)))
			     then (SETQ Win (NC.FetchWindow ID))
				  (NC.AbortCard ID)
				  (if Win
				      then (bind (Process ←(WINDOWPROP Win (QUOTE PROCESS)))
					      until (OR (NULL Process)
							(PROCESS.FINISHEDP Process))
					      do (BLOCK))
					   (CLOSEW Win))))
		   (NC.CacheTypesAndTitles Stream T NIL "Aborting session.")
		   (NC.ForceDatabaseClose Stream)
		   (if (LESSP LastChkptPtr EndPtr)
		       then (NC.PrintMsg NIL T "Truncating file " FullFileName " ...")
			    (COND
			      ((NOT (SETFILEINFO FullFileName (QUOTE LENGTH)
						 LastChkptPtr))
				(NC.PrintMsg NIL NIL "Couldn't truncate " FullFileName "."
					     (CHARACTER 13)))))
		   (NC.ResetMainMenu)
		   (NC.PrintMsg NIL T FullFileName " closed.")
	    else (NC.ClearMsg NIL)))))
)
(PUTPROPS RHTPATCH004 COPYRIGHT ("Xerox Corporation" 1985))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (561 3351 (NC.AbortSession 571 . 3349)))))
STOP