(FILECREATED " 3-Jul-86 16:54:16" {QV}<NOTECARDS>1.3K>KIRKPATCH013.;1 7545   

      changes to:  (VARS KIRKPATCH013COMS foo z))


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

(PRETTYCOMPRINT KIRKPATCH013COMS)

(RPAQQ KIRKPATCH013COMS ((* * fixes minor bugs in prompting for compact files)
			   (FNS NC.NoteFileOperations NC.CompactNoteFile)))
(* * fixes minor bugs in prompting for compact files)

(DEFINEQ

(NC.NoteFileOperations
  (LAMBDA (NoteFile)                                         (* kirk: " 3-Jul-86 16:18")
                                                             (* Ask usere to choose which database operation.
							     Called from main menu whenselected fn.)

          (* * fgh 11/14/85 Updated to handle NoteFile object and per NoteFile menus.)



          (* * kirk 14Jan86 Added Close/Delete cards and changed the format)



          (* * fgh 6/13/86 Now sets BusyOperation of NF menu to something interesting.)



          (* * kirk 3Jul86 passed NoteFileMenuWindow to NC.CompactNoteFile)


    (LET ((NoteFileMenu (fetch (NoteFile Menu) of NoteFile))
	  (Font NC.MenuFont)
	  (FullFileName (fetch (NoteFile FullFileName) of NoteFile))
	  NoteFileMenuWindow Menu)
         (SPAWN.MOUSE)
         (SETQ NoteFileMenuWindow (WFROMMENU NoteFileMenu))
         (OR (SETQ Menu (WINDOWPROP NoteFileMenuWindow (QUOTE DatabaseOperationsMenu)))
	       (WINDOWPROP NoteFileMenuWindow (QUOTE DatabaseOperationsMenu)
			     (SETQ Menu
			       (create MENU
					 ITEMS ←
					 (BQUOTE ((Open (NC.OpenDatabaseFile , NoteFile)
							  "Opens this NoteFile.")
						    (Checkpoint (NC.CheckpointDatabase , NoteFile)
								
						"Checkpoint this NoteFile, saving changed cards.")
						    (Close (NC.CloseDatabaseFile , NoteFile)
							   "Closes this NoteFile.")
						    (Abort (NC.AbortSession , NoteFile)
							   
					     "Close NF, deleteing changes since last checkpoint.")
						    (Compact (NC.CompactNoteFile , NoteFile)
							     "Compacts a NoteFile to a target file."
							     (SUBITEMS (Compact% To% Target% File
									 (NC.CompactNoteFile , 
											 NoteFile , 
											      NIL NIL 
									       NoteFileMenuWindow)
									 
						       "Compacts this NoteFile to a target file.")
								       (Compact% In% Place
									 (NC.CompactNoteFile , 
											 NoteFile NIL 
											       T)
									 
							       "Compacts this NoteFile in place.")))
						    (Inspect&Repair (NC.InspectAndRepairNoteFile
								      , NoteFile)
								    
						 "Inspects and optionally repairs this NoteFile."
								    (SUBITEMS (Read% Substances
										(
								      NC.InspectAndRepairNoteFile
										  , NoteFile T)
										
"Inspects and optionally repairs a Notefile, but reads every substance.  This slows it WAY down.")))
						    (Copy (NC.CopyNoteFile , NoteFile)
							  "Copies this notefile to a target file.")
						    (Rename (NC.RenameNoteFile , NoteFile)
							    "Rename this NoteFile")
						    (Delete (NC.DeleteDatabaseFile
							      (QUOTE , (PACKFILENAME
									 (QUOTE VERSION)
									 NIL
									 (QUOTE BODY)
									 FullFileName))
							      NoteFileMenuWindow)
							    
						   "Deletes the oldest version of this NoteFile.")))
					 CHANGEOFFSETFLG ← (QUOTE Y)
					 MENUOFFSET ← (CONS -1 0)
					 CENTERFLG ← NIL
					 TITLE ← "NoteFile Ops"
					 MENUTITLEFONT ← Font
					 MENUFONT ← Font
					 ITEMHEIGHT ← (IPLUS (FONTPROP Font (QUOTE HEIGHT))
								 1)
					 WHENSELECTEDFN ←
					 (FUNCTION (LAMBDA (Item Menu Button)
					     (WINDOWPROP (WFROMMENU (fetch (NoteFile Menu)
									   of (GETMENUPROP
										  Menu
										  (QUOTE NoteFile)))
									)
							   (QUOTE BusyOperation)
							   (CAR Item))
					     (DEFAULTWHENSELECTEDFN Item Menu Button)))))))
         (PUTMENUPROP Menu (QUOTE NoteFile)
			NoteFile)
         (MENU Menu))))

(NC.CompactNoteFile
  (LAMBDA (FromNoteFile ToFileName InPlaceFlg PromptWindow)
                                                             (* kirk: " 3-Jul-86 16:16")

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


    (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.CompactNoteFileInPlace (OR 
										     FromNoteFile 
										     FromFileName))
					       else        (* compact to target)
						      (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."))))))
)
(PUTPROPS KIRKPATCH013 COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (437 7462 (NC.NoteFileOperations 447 . 4198) (NC.CompactNoteFile 4200 . 7460)))))
STOP