(FILECREATED "20-Oct-86 14:56:49" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH121.;4 7174   

      changes to:  (FNS NCLocalDevice.InspectAndRepairNoteFile NCLocalDevice.CompactNoteFile)
		   (VARS RHTPATCH121COMS)

      previous date: "16-Oct-86 15:36:37" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH121.;1)


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

(PRETTYCOMPRINT RHTPATCH121COMS)

(RPAQQ RHTPATCH121COMS ((* * Changes to make NCREPAIR and NCCOMPACT autoloadable.)
			  (* * Changes to NCLOCALDEVICE)
			  (FNS NCLocalDevice.InspectAndRepairNoteFile NCLocalDevice.CompactNoteFile)
			  (* * Add this P com to NCLOCALDEVICE)
			  (P (NC.StoreAutoloadFnFile (FUNCTION NC.ScavengerPhase1)
						     (QUOTE NCREPAIR)
						     (QUOTE NOTECARDSDIRECTORIES))
			     (NC.StoreAutoloadFnFile (FUNCTION NC.CompactNoteFileInPlace)
						     (QUOTE NCCOMPACT)
						     (QUOTE NOTECARDSDIRECTORIES))
			     (NC.StoreAutoloadFnFile (FUNCTION NC.CompactNoteFileToTarget)
						     (QUOTE NCCOMPACT)
						     (QUOTE NOTECARDSDIRECTORIES)))
			  (* * The functions NC.InspectAndRepairNoteFile and NC.CompactNoteFile 
			     should be moved from NCREPAIR and NCCOMPACT, respectively to NCDATABASE)
			  (P (MOVETOFILE (QUOTE NCDATABASE)
					 (QUOTE NC.InspectAndRepairNoteFile)
					 (QUOTE FNS)
					 (QUOTE NCREPAIR))
			     (MOVETOFILE (QUOTE NCDATABASE)
					 (QUOTE NC.CompactNoteFile)
					 (QUOTE FNS)
					 (QUOTE NCCOMPACT)))
			  (* * Need to remove NCREPAIR and NCCOMPACT from NC.CoreFiles.)))
(* * Changes to make NCREPAIR and NCCOMPACT autoloadable.)

(* * Changes to NCLOCALDEVICE)

(DEFINEQ

(NCLocalDevice.InspectAndRepairNoteFile
  (LAMBDA (NoteFileOrFileName ReadSubstancesFlg InterestedWindow)
                                                             (* rht: "20-Oct-86 14:55")

          (* * Check to be sure file is closed before calling real inspect and repair.)



          (* * rht 7/16/86: Added InterestedWindow arg. Removed call to NC.OpenDatabaseFile.)



          (* * rht 7/17/86: Now works with file name args as well as notefile args. Took out reopen'ing of notefile, because 
	  you don't know how it was originally opened.)



          (* * rht 10/15/86: Now only calls NC.NoteFileOpenP on real notefile objects.)



          (* * rht 10/16/86: Now autoloads NCREPAIR.)


    (LET ((NoteFile (if (type? NoteFile NoteFileOrFileName)
			then NoteFileOrFileName
		      else (NC.NoteFileFromFileName NoteFileOrFileName))))
         (if (AND NoteFile (NC.NoteFileOpenP NoteFile))
	     then (NC.CloseNoteFile NoteFile InterestedWindow))
         (NC.AutoloadApply* (FUNCTION NC.ScavengerPhase1)
			    NoteFileOrFileName ReadSubstancesFlg NIL NIL InterestedWindow))))

(NCLocalDevice.CompactNoteFile
  (LAMBDA (FromNoteFile ToFileName InPlaceFlg PromptWindow)
                                                             (* rht: "20-Oct-86 14:56")

          (* * Compact a NoteFile. If InPlaceFlg is T calls NC.CompactNoteFileInPlace. Otherwise if ToFileName is NIL, asks 
	  for a new file name.)



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



          (* * kirk 19Nov85: Created from NC.CompactDatabaseInPlace to handle new NoteFile format)



          (* * fgh 5/186 Totally rewritten to get rid of numerous bugs. Added new PromptWindow parameter.)



          (* * rht 7/2/86: Fixed bug in call to NC.CompactToTarget and NC.CompactInPlace. They were being called with 
	  FromNoteFile instead of (OR FromNoteFile FromFileName).)



          (* * kirk 3Jul86 Added SETQ NC.DatabaseFileNameSuggestion)



          (* * rht 10/16/86: Now autoloads NCREPAIR.)


    (DECLARE (GLOBALVARS NC.DatabaseFileNameSuggestion))
    (LET (WasOpen FromFileName ToNoteFile success)

          (* * Get the name of the file to be compacted)


         (SETQ FromFileName (COND
	     ((NULL FromNoteFile)
	       (PROG1 (NC.DatabaseFileName "Name of NoteFile to be compacted:" " -- " T NIL NIL 
					       PromptWindow)
			(NC.ClearMsg PromptWindow)))
	     ((type? NoteFile FromNoteFile)
	       (fetch (NoteFile FullFileName) of FromNoteFile))
	     (T FromNoteFile)))

          (* * If compact to target, get the name of the target file)


         (if (NULL InPlaceFlg)
	     then (SETQ NC.DatabaseFileNameSuggestion (PACKFILENAME (QUOTE VERSION)
									  NIL
									  (QUOTE BODY)
									  (FULLNAME FromFileName)))
		    (SETQ ToFileName (OR ToFileName (PROG1 (NC.DatabaseFileName 
								  "Name of target of compaction:"
											" -- " T NIL 
											NIL 
										     PromptWindow)
								 (NC.ClearMsg PromptWindow)))))

          (* * As long as you have file names, go ahead!)


         (if (AND FromFileName (OR InPlaceFlg ToFileName))
	     then 

          (* * Make full names)


		    (SETQ FromFileName (FULLNAME FromFileName (QUOTE OLD)))
		    (SETQ ToFileName (FULLNAME ToFileName (QUOTE NEW))) 

          (* * Close the file if its open)


		    (if (AND (SETQ FromNoteFile (NC.NoteFileFromFileName FromFileName))
				 (SETQ WasOpen (OPENP FromFileName)))
			then (NC.CloseDatabaseFile FromNoteFile))

          (* * Compact the file and reopen if successfull and was previously open)


		    (NC.PrintMsg NIL T "Compacting " FromFileName " ...")
		    (if (SETQ ToNoteFile (if InPlaceFlg
						 then (NC.AutoloadApply* (FUNCTION 
									NC.CompactNoteFileInPlace)
									   (OR FromNoteFile 
										 FromFileName))
					       else        (* compact to target)
						      (NC.AutoloadApply* (FUNCTION 
								       NC.CompactNoteFileToTarget)
									 (OR FromNoteFile 
									       FromFileName)
									 ToFileName)))
			then (if WasOpen
				   then (NC.OpenDatabaseFile ToNoteFile)
				 else (NC.PrintMsg NIL T "Done compacting " FromFileName))
		      else (NC.PrintMsg NIL T "Compact of " FromFileName " cancelled."))))))
)
(* * Add this P com to NCLOCALDEVICE)

(NC.StoreAutoloadFnFile (FUNCTION NC.ScavengerPhase1)
			(QUOTE NCREPAIR)
			(QUOTE NOTECARDSDIRECTORIES))
(NC.StoreAutoloadFnFile (FUNCTION NC.CompactNoteFileInPlace)
			(QUOTE NCCOMPACT)
			(QUOTE NOTECARDSDIRECTORIES))
(NC.StoreAutoloadFnFile (FUNCTION NC.CompactNoteFileToTarget)
			(QUOTE NCCOMPACT)
			(QUOTE NOTECARDSDIRECTORIES))
(* * The functions NC.InspectAndRepairNoteFile and NC.CompactNoteFile should be moved from 
NCREPAIR and NCCOMPACT, respectively to NCDATABASE)

(MOVETOFILE (QUOTE NCDATABASE)
	    (QUOTE NC.InspectAndRepairNoteFile)
	    (QUOTE FNS)
	    (QUOTE NCREPAIR))
(MOVETOFILE (QUOTE NCDATABASE)
	    (QUOTE NC.CompactNoteFile)
	    (QUOTE FNS)
	    (QUOTE NCCOMPACT))
(* * Need to remove NCREPAIR and NCCOMPACT from NC.CoreFiles.)

(PUTPROPS RHTPATCH121 COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (1623 6275 (NCLocalDevice.InspectAndRepairNoteFile 1633 . 2808) (
NCLocalDevice.CompactNoteFile 2810 . 6273)))))
STOP