(FILECREATED "10-Jan-85 00:51:20" {PHYLUM}<NOTECARDS>RELEASE1.1>NCINTERFACE.;9 59112  

      changes to:  (FNS NC.CloseDatabaseFile NC.ForceDatabaseClose NC.SelectNoteCards)

      previous date: " 4-Jan-85 12:17:34" {PHYLUM}<NOTECARDS>RELEASE1.1>NCINTERFACE.;8)


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

(PRETTYCOMPRINT NCINTERFACECOMS)

(RPAQQ NCINTERFACECOMS ((* * Internal variables)
	(GLOBALVARS NC.SelectionInProgress NC.SelectedCards NC.MainMenu NC.SelectingSourcesMenu 
		    NC.SelectingContentsMenu NC.SelectingSingleCardMenu NC.SelectingMultipleCardsMenu 
		    NC.DeleteSelectingMenu (NC.TEditMenus NIL)
		    NC.NoteCardTypeMenu NC.DatabaseOperationsMenu NC.LinkDisplayModesMenu 
		    NC.LinkLabelMenu NC.TopLevelCards NC.MainMenuInProgress NC.WindowRightButtonMenu 
		    NC.MainMenuWindow NC.SelectingCardsMenu)
	(VARS (NC.VersionNumber 1)
	      (NC.LinkLabelMenu NIL)
	      (NC.LinkDisplayModesMenu NIL)
	      (NC.UnclassifiedID (QUOTE NC00003))
	      (NC.TopLevelCards (QUOTE (NC00001 NC00002 NC00003)))
	      (NC.MainMenuInProgress NIL)
	      (NC.DatabaseFileNameSuggestion NIL))
	(* * Setup and top level interaction)
	(FNS NC.MakeMainMenu NC.SetupScreen NC.MainMenuWhenSelectedFn NC.CacheTitles 
	     NC.CacheTypesAndTitles NC.CloseDatabaseFile NC.CompactDatabase NC.DatabaseOperations 
	     NC.LogoutAdvice NC.DatabaseFileName NC.DeleteDatabaseFile INSTALL NC.ForceDatabaseClose 
	     NC.ListDatabaseFiles NC.MakeFloppies NC.MakeSysout NC.AdjustCloseF NC.AdvisedCloseF 
	     NC.CloseNoteCards)
	(* * Menus of all sorts)
	(FNS NC.AskLinkLabel NC.AskNoteCardType NC.ChooseTopLevelCard NC.DisplayMainMenu 
	     NC.RemoveSketchMenuItems NC.SelectionMenusWhenSelectedFn NC.SetupTitleBarMenu 
	     NC.TitleBarButtonEventFn NC.ChooseCloseOrDelete)
	(* * Selection Mechanism)
	(VARS NC.SelectionInProgress)
	(FNS NC.SelectNoteCards)
	(* * Fix up Lisp)
	(ADVISE LOGOUT)
	(* * Set the modification date)
	(E (SETQ NC.SystemDate (DATE)))
	(VARS NC.SystemDate)))
(* * Internal variables)

(DECLARE: DOEVAL@COMPILE DONTCOPY

(GLOBALVARS NC.SelectionInProgress NC.SelectedCards NC.MainMenu NC.SelectingSourcesMenu 
	    NC.SelectingContentsMenu NC.SelectingSingleCardMenu NC.SelectingMultipleCardsMenu 
	    NC.DeleteSelectingMenu (NC.TEditMenus NIL)
	    NC.NoteCardTypeMenu NC.DatabaseOperationsMenu NC.LinkDisplayModesMenu NC.LinkLabelMenu 
	    NC.TopLevelCards NC.MainMenuInProgress NC.WindowRightButtonMenu NC.MainMenuWindow 
	    NC.SelectingCardsMenu)
)

(RPAQQ NC.VersionNumber 1)

(RPAQQ NC.LinkLabelMenu NIL)

(RPAQQ NC.LinkDisplayModesMenu NIL)

(RPAQQ NC.UnclassifiedID NC00003)

(RPAQQ NC.TopLevelCards (NC00001 NC00002 NC00003))

(RPAQQ NC.MainMenuInProgress NIL)

(RPAQQ NC.DatabaseFileNameSuggestion NIL)
(* * Setup and top level interaction)

(DEFINEQ

(NC.MakeMainMenu
  (LAMBDA (DatabaseTitle)                                    (* fgh: "29-Oct-84 00:05")

          (* * Create the NoteCards menus)



          (* * rht 8/1/84: Added def'n for new menu: NC.SelectingFileBoxChildrenMenu)


    (PROG (X (Font (FONTCREATE (QUOTE HELVETICA)
			       12
			       (QUOTE BOLD)))
	     (TitleFont (FONTCREATE (QUOTE HELVETICA)
				    10
				    (QUOTE BOLD)))
	     (Position (OR (POSITIONP NC.MainMenuPosition)
			   (create POSITION
				   XCOORD ← 350
				   YCOORD ← 650))))          (* Main Menu)
          (COND
	    ((type? MENU NC.MainMenu)
	      (WINDOWPROP (WFROMMENU NC.MainMenu)
			  (QUOTE CLOSEFN)
			  NIL)
	      (DELETEMENU NC.MainMenu T)))
          (SETQ NC.MainMenuWindow (WFROMMENU
	      (SETQ NC.MainMenu (create MENU
					ITEMS ←(QUOTE ((Close/Delete NIL 
								"Delete note cards or file boxes")
							(NoteFile% Ops NIL 
							 "Brings up menu of NoteFile operations.")
							(Create NIL 
							      "Create a new NoteCard or FileBox.")
							(Show% Box NIL 
							"Bring up one of the standard FileBoxes.")))
					WHENSELECTEDFN ←(FUNCTION NC.MainMenuWhenSelectedFn)
					CENTERFLG ← T
					MENUBORDERSIZE ← 1
					MENUOUTLINESIZE ← 2
					MENUCOLUMNS ← 2
					MENUFONT ← Font
					TITLE ←(OR (AND (BOUNDP (QUOTE PSA.Database))
							PSA.Database
							(OPENP PSA.Database)
							(CONCAT "NoteFile: "
								(LISTGET (UNPACKFILENAME
									   (FULLNAME PSA.Database))
									 (QUOTE NAME))))
						   "No Open NoteFile")
					MENUPOSITION ← Position
					ITEMHEIGHT ←(IPLUS 10 (FONTPROP Font (QUOTE HEIGHT)))
					ITEMWIDTH ←(IPLUS (STRINGWIDTH (QUOTE Close% Database)
								       Font)
							  20)
					MENUTITLEFONT ← Font))))
          (NC.DisplayMainMenu)
          (SETQ X (create MENU
			  ITEMS ←(QUOTE ((NoSource NIL "Indicates that this note card has no source.")
					  (Done NIL "Indicates that selection is completed.")))
			  WHENSELECTEDFN ←(FUNCTION NC.SelectionMenusWhenSelectedFn)
			  TITLE ← "Selecting Source(s)"
			  CENTERFLG ← T
			  MENUBORDERSIZE ← 1
			  MENUOUTLINESIZE ← 1
			  MENUCOLUMNS ← 2
			  MENUFONT ← Font
			  ITEMHEIGHT ←(IPLUS 10 (FONTPROP Font (QUOTE HEIGHT)))
			  MENUPOSITION ← Position
			  ITEMWIDTH ←(IPLUS (STRINGWIDTH (QUOTE Close% Database)
							 Font)
					    20)
			  MENUTITLEFONT ← TitleFont))
          (SETQ NC.SelectingSourcesMenu X)
          (SETQ X (create MENU
			  ITEMS ←(QUOTE ((NoBox NIL "File in ToBeFiled box.")
					  (Done NIL "Indicates that selection is completed.")))
			  WHENSELECTEDFN ←(FUNCTION NC.SelectionMenusWhenSelectedFn)
			  TITLE ← "Selecting File Box(es)"
			  CENTERFLG ← T
			  MENUBORDERSIZE ← 1
			  MENUOUTLINESIZE ← 1
			  MENUCOLUMNS ← 2
			  MENUFONT ← Font
			  ITEMHEIGHT ←(IPLUS 10 (FONTPROP Font (QUOTE HEIGHT)))
			  MENUPOSITION ← Position
			  ITEMWIDTH ←(IPLUS (STRINGWIDTH (QUOTE Close% Database)
							 Font)
					    20)
			  MENUTITLEFONT ← TitleFont))
          (SETQ NC.SelectingContentsMenu X)
          (SETQ X (create MENU
			  ITEMS ←(QUOTE ((New% Card NIL "Make a new note card.")
					  (Cancel NIL "Cancel this selection.")))
			  WHENSELECTEDFN ←(FUNCTION NC.SelectionMenusWhenSelectedFn)
			  TITLE ← "Selecting Note Card"
			  CENTERFLG ← T
			  MENUBORDERSIZE ← 1
			  MENUOUTLINESIZE ← 1
			  MENUCOLUMNS ← 2
			  MENUFONT ← Font
			  ITEMHEIGHT ←(IPLUS 10 (FONTPROP Font (QUOTE HEIGHT)))
			  MENUPOSITION ← Position
			  ITEMWIDTH ←(IPLUS (STRINGWIDTH (QUOTE Close% Database)
							 Font)
					    20)
			  MENUTITLEFONT ← TitleFont))
          (SETQ NC.SelectingSingleCardMenu X)
          (SETQ X (create MENU
			  ITEMS ←(QUOTE ((New% Card NIL "Make a new note card.")
					  (Done NIL "Indicates that selection is completed.")))
			  WHENSELECTEDFN ←(FUNCTION NC.SelectionMenusWhenSelectedFn)
			  TITLE ← "Selecting Note Cards"
			  CENTERFLG ← T
			  MENUBORDERSIZE ← 1
			  MENUOUTLINESIZE ← 1
			  MENUCOLUMNS ← 2
			  MENUFONT ← Font
			  ITEMHEIGHT ←(IPLUS 10 (FONTPROP Font (QUOTE HEIGHT)))
			  MENUPOSITION ← Position
			  ITEMWIDTH ←(IPLUS (STRINGWIDTH (QUOTE Close% Database)
							 Font)
					    20)
			  MENUTITLEFONT ← TitleFont))
          (SETQ NC.SelectingMultipleCardsMenu X)
          (SETQ X (create MENU
			  ITEMS ←(QUOTE ((Cancel NIL "Cancel this selection.")
					  (Done NIL "Indicates that selection is completed.")))
			  WHENSELECTEDFN ←(FUNCTION NC.SelectionMenusWhenSelectedFn)
			  TITLE ← "Selecting Deletions"
			  CENTERFLG ← T
			  MENUBORDERSIZE ← 1
			  MENUOUTLINESIZE ← 1
			  MENUCOLUMNS ← 2
			  MENUFONT ← Font
			  ITEMHEIGHT ←(IPLUS 10 (FONTPROP Font (QUOTE HEIGHT)))
			  MENUPOSITION ← Position
			  ITEMWIDTH ←(IPLUS (STRINGWIDTH (QUOTE Close% Database)
							 Font)
					    20)
			  MENUTITLEFONT ← TitleFont))
          (SETQ NC.DeleteSelectingMenu X)
          (SETQ X (create MENU
			  ITEMS ←(QUOTE ((Cancel NIL "Cancel this selection.")
					  (Done NIL "Indicates that selection is completed.")))
			  WHENSELECTEDFN ←(FUNCTION NC.SelectionMenusWhenSelectedFn)
			  TITLE ← "Selecting FileBox"
			  CENTERFLG ← T
			  MENUBORDERSIZE ← 1
			  MENUOUTLINESIZE ← 1
			  MENUCOLUMNS ← 2
			  MENUFONT ← Font
			  ITEMHEIGHT ←(IPLUS 10 (FONTPROP Font (QUOTE HEIGHT)))
			  MENUPOSITION ← Position
			  ITEMWIDTH ←(IPLUS (STRINGWIDTH (QUOTE Close% Database)
							 Font)
					    20)
			  MENUTITLEFONT ← TitleFont))
          (SETQ NC.SelectingParentsMenu X)
          (SETQ X (create MENU
			  ITEMS ←(QUOTE ((Cancel NIL "Cancel this selection.")))
			  WHENSELECTEDFN ←(FUNCTION NC.SelectionMenusWhenSelectedFn)
			  TITLE ← "Selecting Root Card/Box"
			  CENTERFLG ← T
			  MENUBORDERSIZE ← 1
			  MENUOUTLINESIZE ← 1
			  MENUFONT ← Font
			  ITEMHEIGHT ←(IPLUS 10 (FONTPROP Font (QUOTE HEIGHT)))
			  MENUPOSITION ← Position
			  MENUTITLEFONT ← TitleFont))
          (SETQ NC.SelectingBrowserSourceMenu X)
          (SETQ X (create MENU
			  ITEMS ←(QUOTE ((Cancel NIL "Cancel this operation.")
					  (Done NIL "Indicates that this operation is completed.")))
			  WHENSELECTEDFN ←(FUNCTION NC.SelectionMenusWhenSelectedFn)
			  TITLE ← "Selecting child cards"
			  CENTERFLG ← T
			  MENUBORDERSIZE ← 1
			  MENUOUTLINESIZE ← 1
			  MENUCOLUMNS ← 2
			  MENUFONT ← Font
			  ITEMHEIGHT ←(IPLUS 10 (FONTPROP Font (QUOTE HEIGHT)))
			  MENUPOSITION ← Position
			  ITEMWIDTH ←(IPLUS (STRINGWIDTH (QUOTE Close% Database)
							 Font)
					    20)
			  MENUTITLEFONT ← TitleFont))
          (SETQ NC.SelectingFileBoxChildrenMenu X)
          (SETQ X (create MENU
			  ITEMS ←(QUOTE ((Cancel NIL "Cancel this operation.")
					  (Done NIL "Indicates that this operation is completed.")))
			  WHENSELECTEDFN ←(FUNCTION NC.SelectionMenusWhenSelectedFn)
			  TITLE ← "Selecting Cards"
			  CENTERFLG ← T
			  MENUBORDERSIZE ← 1
			  MENUOUTLINESIZE ← 1
			  MENUCOLUMNS ← 2
			  MENUFONT ← Font
			  ITEMHEIGHT ←(IPLUS 10 (FONTPROP Font (QUOTE HEIGHT)))
			  MENUPOSITION ← Position
			  ITEMWIDTH ←(IPLUS (STRINGWIDTH (QUOTE Close% Database)
							 Font)
					    20)
			  MENUTITLEFONT ← TitleFont))
          (SETQ NC.SelectingCardsMenu X))))

(NC.SetupScreen
  (LAMBDA NIL                                                (* fgh: " 3-Jan-85 14:09")

          (* * Setup the standard NoteCards screen)


    (AND (BOUNDP (QUOTE LOGOW))
	 (WINDOWP LOGOW)
	 (CLOSEW LOGOW))
    (AND (BOUNDP (QUOTE NC.LogoWindow))
	 (WINDOWP NC.LogoWindow)
	 (CLOSEW NC.LogoWindow))
    (NC.MakeLogoWindow)
    (MOVEW NC.LogoWindow 5 605)
    (TTY.PROCESS T)
    (SETQ ExecWindow (WFROMDS (TTYDISPLAYSTREAM)))
    (WINDOWPROP ExecWindow (QUOTE TITLE)
		NIL)
    (SHAPEW ExecWindow (CREATEREGION 608 650 267 66))
    (WINDOWPROP PROMPTWINDOW (QUOTE TITLE)
		NIL)
    (SHAPEW PROMPTWINDOW (CREATEREGION 350 721 526 78))
    (CROCK (CREATEREGION 882 650 127 147))
    (CLEARW PROMPTWINDOW)
    (CLEARW ExecWindow)
    (LAFITE (QUOTE OFF))
    (AND (BOUNDP (QUOTE PROCESS.STATUS.WINDOW))
	 (WINDOWP PROCESS.STATUS.WINDOW)
	 (CLOSEW PROCESS.STATUS.WINDOW))))

(NC.MainMenuWhenSelectedFn
  (LAMBDA (Item Menu Button)                                 (* fgh: "29-Oct-84 00:05")
                                                             (* Function called when one of the items in the top 
							     level menu is chosen.)
    (COND
      ((NULL NC.MainMenuInProgress)
	(RESETLST (RESETSAVE NC.MainMenuInProgress T)
		  (RESETSAVE (SHADEITEM Item Menu GRAYSHADE)
			     (LIST (QUOTE SHADEITEM)
				   Item Menu WHITESHADE))
		  (COND
		    ((AND (NEQ (CAR Item)
			       (QUOTE NoteFile% Ops))
			  (OR (NULL PSA.Database)
			      (NOT (OPENP PSA.Database))))
		      (NC.PrintMsg NIL T "There is no open NoteFile." (CHARACTER 13)
				   
			    "A NoteFile must be opened before any operations can be carried out."
				   (CHARACTER 13)
				   
			      "Press NoteFile Ops to initiate the process of opening a database."
				   (CHARACTER 13)))
		    (T (SETQ NC.MainMenuInProgress (CAR Item))
		       (SELECTQ (CAR Item)
				(Create (COND
					  ((EQ Button (QUOTE LEFT))
					    (NC.MakeNoteCard NC.DefaultCardType))
					  (T (NC.MakeNoteCard))))
				(Show% Box (COND
					     ((EQ Button (QUOTE LEFT))
					       (NC.EditNoteCard NC.RootID))
					     (T (NC.ChooseTopLevelCard))))
				(Close/Delete (NC.ChooseCloseOrDelete))
				(NoteFile% Ops (NC.DatabaseOperations PSA.Database))
				NIL)))))
      (T (NC.PrintMsg NIL NIL (CHARACTER 13)
		      NC.MainMenuInProgress " in progress.  Please wait.")))))

(NC.CacheTitles
  (LAMBDA (DatabaseStream UncacheFlg QuietFlg OperationMsg)
                                                             (* fgh: "13-Aug-84 23:41")
                                                             (* Cache or uncache all of the titles on DatabaseSteam 
							     onto the prop lists of the NoteCard IDs)
    (PROG (CardTotal Title)
          (for CardNumber from 1 to (SETQ CardTotal (SUB1 (SUBATOM (NC.GetNewID DatabaseStream T)
								   3)))
	     do (COND
		  ((AND (NULL QuietFlg)
			(ZEROP (IREMAINDER CardNumber 10)))
		    (NC.PrintMsg NIL T (COND
				   (OperationMsg (CONCAT OperationMsg (CHARACTER 13)))
				   (T ""))
				 "Processing item number " CardNumber " out of " CardTotal "."
				 (CHARACTER 13))))
		(SETQ ID (NC.IDFromNumber CardNumber))
		(COND
		  (UncacheFlg (REMPROP ID (QUOTE NoteCardTitle)))
		  (T (SETQ Title (NC.GetTitle ID DatabaseStream T))
		     (AND (NOT (FMEMB Title (QUOTE (FREE DELETED SPECIAL))))
			  (NC.SetTitle ID Title))))))))

(NC.CacheTypesAndTitles
  (LAMBDA (DatabaseStream UncacheFlg QuietFlg OperationMsg)
                                                             (* fgh: " 6-Nov-84 20:20")
                                                             (* Cache or uncache all of the titles on DatabaseSteam 
							     onto the prop lists of the NoteCard IDs)
    (PROG (CardTotal Pair)
          (for CardNumber from 1 to (SETQ CardTotal (SUB1 (SUBATOM (NC.GetNewID DatabaseStream T)
								   3)))
	     do (COND
		  ((AND (NULL QuietFlg)
			(ZEROP (IREMAINDER CardNumber 10)))
		    (NC.PrintMsg NIL T (COND
				   (OperationMsg (CONCAT OperationMsg (CHARACTER 13)))
				   (T ""))
				 "Processing item number " CardNumber " out of " CardTotal "."
				 (CHARACTER 13))))
		(SETQ ID (NC.IDFromNumber CardNumber))
		(COND
		  (UncacheFlg (AND (NC.ActiveCardP ID)
				   (NC.QuitCard ID T))
			      (SETPROPLIST ID NIL))
		  (T (SETQ Pair (NC.GetTypeAndTitle ID DatabaseStream T))
		     (COND
		       ((NOT (FMEMB Pair (QUOTE (FREE DELETED SPECIAL))))
			 (NC.SetTitle ID (CDR Pair))
			 (NC.SetType ID (CAR Pair))))))))))

(NC.CloseDatabaseFile
  (LAMBDA NIL                                                (* rht: " 9-Jan-85 16:00")
                                                             (* Close the currently open database file.)

          (* * rht 10/23/84: Now gives user option of closing and saving all open cards on the screen.)



          (* * rht 11/8/84: Put RESETLST around NC.CacheTitles call.)



          (* * rht 1/9/85: Clear the NC.UncachingNotCompleted variable when close successfully completes.)


    (PROG (File CardTotal ID OpenWindows)
          (COND
	    ((OR (NULL PSA.Database)
		 (NOT (OPENP PSA.Database)))
	      (NC.PrintMsg NIL T "There is no open NoteFile!!!" (CHARACTER 13)))
	    (T (COND
		 ((SETQ OpenWindows (for Window in (OPENWINDOWS)
				       when (NC.ActiveCardP (OR (NC.IDFromWindow Window)
								(NC.IDFromWindow (WINDOWPROP
										   Window
										   (QUOTE ICONFOR)))))
				       collect Window))
		   (NC.PrintMsg NIL T "There are cards still active on the screen." (CHARACTER 13))
		   (COND
		     ((NC.YesP (NC.AskUser "Want to close and save them? " " -- " (QUOTE Yes)))
		       (NC.PrintMsg NIL T "Closing and saving active cards ... ")
		       (RESETLST (RESETSAVE NC.ForceSourcesFlg NIL)
				 (RESETSAVE NC.ForceFilingFlg NIL)
				 (RESETSAVE NC.ForceTitlesFlg NIL)
				 (for Window in OpenWindows
				    do (COND
					 ((WINDOWPROP Window (QUOTE ICONFOR))
					   (SETQ Window (EXPANDW Window))))
				       (NC.QuitCard (NC.IDFromWindow Window)
						    T)
				       (until (NULL (OPENWP Window)) do (BLOCK))))
		       (NC.PrintMsg NIL NIL "Done." (CHARACTER 13)))
		     (T (RETURN NIL)))))
	       (NC.PrintMsg NIL T "Closing Notefile ... " (CHARACTER 13))
	       (RESETLST (RESETSAVE NC.ForceSourcesFlg NIL)
			 (RESETSAVE NC.ForceFilingFlg NIL)
			 (RESETSAVE NC.ForceTitlesFlg NIL)
			 (NC.CacheTypesAndTitles PSA.Database T NIL "Closing NoteFile."))
	       (NC.SaveNextLinkID PSA.Database T)
	       (SETQ File (FULLNAME PSA.Database))

          (* * Set PSA.Database GlobalVar to NIL so that the advise to CLOSEF will not refuse to close this file.)


	       (NC.ForceDatabaseClose PSA.Database)
	       (replace (MENU TITLE) of NC.MainMenu with "No Open NoteFile")
	       (replace (MENU IMAGE) of NC.MainMenu with NIL)
	       (WINDOWPROP (WFROMMENU NC.MainMenu)
			   (QUOTE CLOSEFN)
			   NIL)
	       (NC.DisplayMainMenu)
	       (SETQ PSA.Database)
	       (NC.PrintMsg NIL T File " closed.")
	       (SETQ NC.UncachingNotCompleted NIL))))))

(NC.CompactDatabase
  (LAMBDA (FileName)                                         (* fgh: "17-Oct-84 16:53")
                                                             (* Top-level call to the database compactor.)

          (* * rht 8/7/84: Changes NC.DatabaseFileNameSuggestion to the name of the compacted file.)


    (COND
      ((AND PSA.Database (OPENP PSA.Database))
	(NC.PrintMsg NIL T "There is an open NoteFile." (CHARACTER 13)
		     "The NoteFile must be closed before any other NoteFile can be compacted."
		     (CHARACTER 13)))
      (T (OR FileName (SETQ FileName (NC.DatabaseFileName "Name of NoteFile to be compacted:" " -- " 
							  T)))
	 (NC.ClearMsg)
	 (COND
	   ((SETQ FileName (NC.FastCompactDatabase FileName FileName NIL))
	     (NC.PrintMsg NIL T (CADR FileName)
			  " compacted."
			  (CHARACTER 13))
	     (SETQ NC.DatabaseFileNameSuggestion (PACKFILENAME (QUOTE VERSION)
							       NIL
							       (QUOTE BODY)
							       (CADR FileName)))))))))

(NC.DatabaseOperations
  (LAMBDA NIL                                                (* fgh: "13-Aug-84 23:16")
                                                             (* Ask usere to choose which database operation.
							     Called from main menu whenselected fn.)
    (PROG (Menu W Z (Font (FONTCREATE (QUOTE HELVETICA)
				      10
				      (QUOTE BOLD))))
          (SPAWN.MOUSE)
          (SETQ Menu (OR (AND (BOUNDP (QUOTE NC.DatabaseOperationsMenu))
			      (type? MENU NC.DatabaseOperationsMenu)
			      NC.DatabaseOperationsMenu)
			 (SETQ NC.DatabaseOperationsMenu (create MENU
								 ITEMS ←(QUOTE ((Change% Parameters
										   (NC.BuildInspector)
										   
						"Bring up editor to change NoteCards parameters.")
										 (Open% NoteFile
										   (
NC.OpenDatabaseFile)
										   
									      "Opens a NoteFile.")
										 (Close% NoteFile
										   (
NC.CloseDatabaseFile)
										   
							    "Closes the currently open NoteFile.")
										 (List% NoteFiles
										   (
NC.ListDatabaseFiles)
										   
				    "Lists all of the NoteFiles stored in the current directory.")
										 (
Create% New% NoteFile (NC.CreateDatabaseFile)
		      "Creates a new (empty) NoteFile.")
										 (Compact% NoteFile
										   (NC.CompactDatabase
										     )
										   
									   "Compacts a NoteFile.")
										 (Repair% NoteFile
										   (
NC.ScavengeDatabaseFile NIL T)
										   
							      "Repairs an inconsistent NoteFile.")
										 (Delete% NoteFile
										   (
NC.DeleteDatabaseFile NIL)
										   
						      "Deletes the oldest version of a NoteFile.")
										 (
Restore% From% Floppy (NC.FloppyArchive NIL T)
		      "Retrieves a NoteFile that has been backed up on a floppy.")
										 (Backup% To% Floppy
										   (NC.FloppyArchive
										     NIL NIL)
										   
						      "Makes a backup of a NoteFile on a floppy.")))
								 CENTERFLG ← T
								 TITLE ← "Operation?"
								 MENUFONT ← Font
								 ITEMHEIGHT ←(IPLUS
								   (FONTPROP Font (QUOTE HEIGHT))
								   1)))))
          (SETQ W (MENUITEMREGION (CAR (NTH (fetch (MENU ITEMS) of NC.MainMenu)
					    2))
				  NC.MainMenu))
          (SETQ Z (WINDOWPROP (WFROMMENU NC.MainMenu)
			      (QUOTE REGION)))
          (replace MENUPOSITION of NC.DatabaseOperationsMenu
	     with (CONS (IPLUS (fetch (REGION LEFT) of W)
			       (fetch (REGION LEFT) of Z))
			(IPLUS (fetch (REGION TOP) of W)
			       (fetch (REGION BOTTOM) of Z)
			       (IMINUS (fetch (MENU IMAGEHEIGHT) of NC.DatabaseOperationsMenu)))))
          (MENU NC.DatabaseOperationsMenu))))

(NC.LogoutAdvice
  (LAMBDA NIL                                                (* fgh: "13-Aug-84 23:41")
                                                             (* Advice attached to logout to prevent logging out 
							     with an open database.)
    (COND
      ((AND (BOUNDP (QUOTE PSA.Database))
	    (STREAMP PSA.Database)
	    (OPENP PSA.Database))
	(NC.PrintMsg NIL T "There is an open NoteFile: " (FULLNAME PSA.Database)
		     (CHARACTER 13)
		     "It must be closed before you can logout!!!"
		     (CHARACTER 13))
	(RPTQ 1 (PROGN (VIDEOCOLOR T)
		       (DISMISS 100)
		       (VIDEOCOLOR NIL)
		       (DISMISS 100)))
	(RPTQ 3 (FLASHW PROMPTWINDOW))
	(RETFROM (QUOTE LOGOUT))))))

(NC.DatabaseFileName
  (LAMBDA (Msg Prompt ClearFirstFlg NoSuggestFlg Name)       (* rht: "18-Dec-84 15:35")
                                                             (* Make a NoteCards database file name on the base 
							     specified by the user. Basically, add the NOTEFILE 
							     extension)

          (* * rht 8/7/84: Now provides file name suggestion for user (unless NoSuggestFlg is non-nil.) The suggestion is in 
	  the global var NC.DatabaseFileNameSuggestion which is reset to the new file name before returning.)


    (PROG NIL
          (OR Name (SETQ Name (MKATOM (NC.AskUser Msg Prompt (AND (NOT NoSuggestFlg)
								  NC.DatabaseFileNameSuggestion)
						  ClearFirstFlg NIL T))))
          (AND (NULL Name)
	       (RETURN NIL))
          (SETQ Name (PACKFILENAME (QUOTE BODY)
				   Name
				   (QUOTE EXTENSION)
				   (QUOTE NOTEFILE)))
          (SETQ NC.DatabaseFileNameSuggestion (PACKFILENAME (QUOTE VERSION)
							    NIL
							    (QUOTE BODY)
							    (FULLNAME Name)))
          (RETURN Name))))

(NC.DeleteDatabaseFile
  (LAMBDA (FileName)                                         (* fgh: " 8-Oct-84 19:12")
                                                             (* Delete file FileName)
    (PROG (FullFileName)                                     (* Make sure no open databases)

          (* * rht 8/7/84: If delete happens, clear NC.DatabaseFileNameSuggestion.)


          (COND
	    ((AND PSA.Database (OPENP PSA.Database))
	      (NC.PrintMsg NIL T "There is an open NoteFile." (CHARACTER 13)
			   "The NoteFile must be closed" " before any NoteFile can be " "deleted."
			   (CHARACTER 13))
	      (RETURN)))                                     (* Get file name)
          (AND (NULL FileName)
	       (NULL (SETQ FileName (NC.DatabaseFileName "Name of Notefile to be deleted:" " -- " T)))
	       (RETURN NIL))                                 (* make sure to be deleted file exists)
          (SETQ FullFileName (CAR (FILDIR-EARLIEST FileName)))
          (COND
	    ((NULL FullFileName)
	      (NC.PrintMsg NIL T FileName " does not exist." (CHARACTER 13)
			   "Delete cancelled."
			   (CHARACTER 13))
	      (RETURN)))                                     (* Ask user to confirm twice.)
          (COND
	    ((NOT (FMEMB (MKATOM (NC.AskUser (CONCAT "Are you sure you want to delete " FullFileName 
						     "?")
					     " -- " "No" T NIL T))
			 (QUOTE (Y y Yes YES))))
	      (NC.ClearMsg NIL NIL)
	      (RETURN)))
          (NC.PrintMsg NIL T "Deleteing " FullFileName (CHARACTER 13))
          (DISMISS 2500)
          (COND
	    ((NOT (FMEMB (MKATOM (NC.AskUser (CONCAT "Are you STILL sure you want to delete " 
						     FullFileName "?")
					     " -- " "No" T NIL T))
			 (QUOTE (Y y Yes YES))))
	      (NC.ClearMsg NIL NIL)
	      (RETURN)))                                     (* Delete the file)
          (SETQ FullFileName (DELFILE FullFileName))
          (SETQ NC.DatabaseFileNameSuggestion NIL)
          (NC.PrintMsg NIL T FullFileName " deleted." (CHARACTER 13)))))

(INSTALL
  (LAMBDA NIL                                                (* fgh: "13-Aug-84 23:41")

          (* NoteCards system installatiuon routine. For DLions only. Basically to a MKDIR on DLION disk and copy the font 
	  files from floppy to local disk. To be run only after the DLion local disk has been repartitioned.)


    (COND
      ((EQ (MACHINETYPE)
	   (QUOTE DANDELION))
	(RESETLST (RESETSAVE NIL (LIST (QUOTE WINDOWPROP)
				       ExecWindow
				       (QUOTE PAGEFULLFN)
				       (WINDOWPROP ExecWindow (QUOTE PAGEFULLFN)
						   (FUNCTION NILL))))
		  (COND
		    ((NOT (DFSLISPVOLUMEP (QUOTE DSK)))
		      (MKDIR (QUOTE DSK))))
		  (PROG (Files FloppyName)
		        (NC.ClearMsg NIL NIL)
		    Loop(NC.PrintMsg NIL NIL "Please insert the Lisp Library #2" 
				     " diskette in the floppy disk drive."
				     (CHARACTER 13))
		        (FLOPPY.WAIT.FOR.FLOPPY)
		        (NC.PrintMsg NIL T "NoteCards Initialization." (CHARACTER 13)
				     "Examining files on the Lisp Library #2" " diskette."
				     (CHARACTER 13)
				     "Please wait ... "
				     (CHARACTER 13))
		        (COND
			  ((AND (NEQ (SETQ FloppyName (FLOPPY.NAME))
				     (QUOTE LispLibrary2))
				(NEQ FloppyName (QUOTE LispPackages)))
			    (NC.PrintMsg NIL T "The floppy currently in the drive is named: " 
					 FloppyName (CHARACTER 13)
					 "Please insert the correct diskette."
					 (CHARACTER 13))
			    (GO Loop))
			  (T (SETQ Files (FILDIR (QUOTE {FLOPPY}*.STRIKE)))
			     (COND
			       ((NULL Files)
				 (NC.PrintMsg NIL T "There are no font files on this diskette."
					      (CHARACTER 13)
					      "Please insert the correct diskette."
					      (CHARACTER 13))
				 (GO Loop))
			       (T (NC.PrintMsg NIL T "NoteCards Initialization." (CHARACTER 13)
					       "Copying files from the Lisp Library #2" 
					       " diskette to hard disk."
					       (CHARACTER 13)
					       "Please wait ... "
					       (CHARACTER 13))
				  (for File in Files do (COPYFILE File (PACKFILENAME (QUOTE HOST)
										     (QUOTE DSK)
										     (QUOTE VERSION)
										     NIL
										     (QUOTE BODY)
										     File)))
				  (COPYFILE (QUOTE {FLOPPY}FONTS.WIDTHS)
					    (QUOTE {DSK}FONTS.WIDTHS))))))))))
    (NC.PrintMsg NIL T "NoteCards System Installation Completed." (CHARACTER 13))
    (QUOTE Done)))

(NC.ForceDatabaseClose
  (LAMBDA (DatabaseStream)                                   (* rht: " 9-Jan-85 23:05")

          (* * Really close the database, i.e.. bypass the ADVISE on CLOSEF that prevents closing of the database.)


    (SETQ PSA.Database NIL)
    (CLOSEF DatabaseStream)))

(NC.ListDatabaseFiles
  (LAMBDA NIL                                                (* fgh: "13-Aug-84 23:44")
                                                             (* Do a DIR on all of the NoteFiles on the current 
							     connected directory.)
    (PROG (Files)
          (RESETLST (RESETSAVE (TTYDISPLAYSTREAM PROMPTWINDOW))
		    (RESETSAVE NIL (LIST (QUOTE WINDOWPROP)
					 PROMPTWINDOW
					 (QUOTE PAGEFULLFN)
					 (WINDOWPROP PROMPTWINDOW (QUOTE PAGEFULLFN)
						     NIL)))
		    (GIVE.TTY.PROCESS PROMPTWINDOW)
		    (CLEARBUF T)
		    (SETQ Files (FILDIR (QUOTE *.NoteFile)))
		    (COND
		      (Files (CLRPROMPT)
			     (for File in Files do (printout PROMPTWINDOW "NoteFile:  " File T)))
		      (T (NC.PrintMsg NIL T "There are no NoteFiles" 
				      " (files ending in .NoteFile) in "
				      (DIRECTORYNAME T))))))))

(NC.MakeFloppies
  (LAMBDA NIL                                                (* NoteCards% User "12-Jun-84 23:09")
                                                             (* Make sysout on floppies for loading by NoteCards 
							     installation Prometheus script)
    (RESETLST (RESETSAVE (FLOPPY.MODE (QUOTE SYSOUT)))
	      (RESETSAVE (ADVISE (QUOTE \PFLOPPY.FORMAT)
				 (QUOTE BEFORE)
				 (QUOTE (SETQ NAME (CONCAT "NoteCards Sysout #"
							   (SUBSTRING NAME -1 -1)))))
			 (QUOTE (UNADVISE \PFLOPPY.FORMAT)))
	      (COPYFILE (QUOTE {PHYLUM}<PSA>NOTECARDS>NOTECARDS.SYSOUT)
			(QUOTE {FLOPPY})))))

(NC.MakeSysout
  (LAMBDA NIL                                                (* NoteCards% User "13-Jun-84 00:03")
                                                             (* Make the NoteCards sysout -
							     making sure that the correct logion, etc is done on 
							     coming back from the sysout)
    (PROG (OldPageFullFn)
          (AND (BOUNDP (QUOTE LOGOW))
	       (WINDOWP LOGOW)
	       (CLOSEW LOGOW))
          (COND
	    ((OR (NOT (BOUNDP (QUOTE QUADTREE.HIGHRES)))
		 (NLISTP (QUOTE QUADTREE.HIGHRES)))
	      (SETQ QUADTREE.HIGHRES (GET.QUAD.TREE (QUOTE WORLD5)))))
          (SETQ World5File (QUOTE {DSK}WORLD5.MAPDATA))
          (SETQ FONTDIRECTORIES (LIST (QUOTE {DSK})))
          (NC.MakeLogoWindow)
          (MOVEW NC.LogoWindow 5 605)
          (TTY.PROCESS T)
          (SETQ ExecWindow (WFROMDS (TTYDISPLAYSTREAM)))
          (SETQ OldPageFullFn (WINDOWPROP ExecWindow (QUOTE PAGEFULLFN)
					  (FUNCTION NILL)))
          (WINDOWPROP ExecWindow (QUOTE TITLE)
		      NIL)
          (SHAPEW ExecWindow (CREATEREGION 608 650 267 66))
          (WINDOWPROP PROMPTWINDOW (QUOTE TITLE)
		      NIL)
          (SHAPEW PROMPTWINDOW (CREATEREGION 350 721 526 78))
          (CROCK (CREATEREGION 882 650 127 147))
          (CLEARW PROMPTWINDOW)
          (CLEARW ExecWindow)
          (SYSOUT (QUOTE {DSK4}NOTECARDS.SYSOUT;1))
          (CLEARW ExecWindow)
          (WINDOWPROP ExecWindow (QUOTE PAGEFULLFN)
		      OldPageFullFn)
          (LOGIN)
          (USERNAME)
          (RETURN (QUOTE NoteCards)))))

(NC.AdjustCloseF
  (LAMBDA NIL                                                (* fgh: "28-Oct-84 22:25")

          (* * Essentially Advise CLOSEF buit do it in a way that can be compiled)


    (COND
      ((NOT (EQUAL (GETD (QUOTE CLOSEF))
		   (GETD (QUOTE NC.AdvisedCloseF))))
	(MOVD (QUOTE CLOSEF)
	      (QUOTE NC.OldCloseF))
	(MOVD (QUOTE NC.AdvisedCloseF)
	      (QUOTE CLOSEF))))))

(NC.AdvisedCloseF
  (LAMBDA (FILE)                                             (* fgh: "28-Oct-84 22:15")

          (* * Essentially CLOSEF but prevent PSA.Databse from being closed!!! A compiled advise kludge this is.)


    (AND (NEQ FILE PSA.Database)
	 (NC.OldCloseF FILE))))

(NC.CloseNoteCards
  (LAMBDA (CardTextStreamWindowOrID NoCheckFlg DontClearFlg)
                                                             (* fgh: " 6-Nov-84 20:21")

          (* * Close note acrds on the screen)


    (PROG (ID Cards Window)
          (SETQ Cards (COND
	      ((NULL CardTextStreamWindowOrID)
		(NC.PrintMsg NIL T "Please select the cards to be closed." (CHARACTER 13))
		(NC.SelectNoteCards NIL NIL NC.DeleteSelectingMenu))
	      (T CardTextStreamWindowOrID)))
          (SPAWN.MOUSE)
          (for Card in (MKLIST Cards)
	     do (SETQ ID (COND
		    ((WINDOWP Card)
		      (NC.IDFromWindow Card))
		    ((NC.IDP Card)
		      Card)
		    ((TEXTSTREAMP Card)
		      (NC.IDFromWindow (WINDOW.FROM.TEDIT.THING Card)))))
		(COND
		  ((AND (NC.ActiveCardP ID)
			(SETQ Window (NC.FetchWindow ID)))
		    (NC.QuitCard ID T)
		    (while (OPENWP Window) do (BLOCK))))))))
)
(* * Menus of all sorts)

(DEFINEQ

(NC.AskLinkLabel
  (LAMBDA (MainWindow MultipleFlg SystemLinksFlg NewLinkFlg CancelOkayFlg ReverseLinksFlg)
                                                             (* rht: "22-Nov-84 10:40")
                                                             (* Asks for label on notecard links)

          (* * rht 8/2/84: Added double columns for when called by the browser, i.e. ReverseLinksFlg=T.
	  Reverse links have prefix "←".)



          (* * rht 11/19/84: Changed strings from "pointer" to "link" and from "label" to "type".)


    (PROG (Menu Choice LabelsList (LinkLabels (NC.RetrieveLinkLabels PSA.Database SystemLinksFlg)))
          (GETPROMPTWINDOW MainWindow 3 (FONTCREATE (QUOTE HELVETICA)
						    10))
          (NC.PrintMsg MainWindow T (COND
			 (MultipleFlg "Please choose link type(s).")
			 (T "Please choose link type."))
		       (CHARACTER 13)
		       "Link types chosen: ")
          (SETQ Menu (create MENU
			     TITLE ←(COND
			       (MultipleFlg "Link Type(s)?")
			       (T "Link Type?"))
			     ITEMS ←(NCONC (COND
					     (ReverseLinksFlg (for Link in LinkLabels
								 join (LIST Link (CONCAT "←" Link))))
					     (T (COPY LinkLabels)))
					   (AND MultipleFlg (LIST (QUOTE --ALL--)))
					   (AND MultipleFlg ReverseLinksFlg (LIST (QUOTE --←ALL--)))
					   (AND MultipleFlg (LIST (QUOTE --DONE--)))
					   (AND NewLinkFlg (LIST (QUOTE --New% Link% Type--)))
					   (AND CancelOkayFlg (LIST (QUOTE **CANCEL**))))
			     MENUPOSITION ←(AND (WINDOWP MainWindow)
						(create POSITION
							XCOORD ←(fetch (REGION LEFT)
								   of (WINDOWPROP MainWindow
										  (QUOTE REGION)))
							YCOORD ←(fetch (REGION TOP)
								   of (WINDOWREGION MainWindow))))
			     MENUCOLUMNS ←(AND ReverseLinksFlg 2)))
          (RETURN (PROG1 (until NIL
			    do (SETQ Choice (OR (MKATOM (MENU Menu))
						NC.UnspecifiedLinkLabel))
			       (COND
				 ((EQ Choice (QUOTE **CANCEL**))
				   (SETQ Choice))
				 ((EQ Choice (QUOTE --New% Link% Type--))
				   (NC.ClearMsg MainWindow NIL)
				   (until (COND
					    ((NOT (FMEMB (U-CASE (SETQ Choice
								   (MKATOM (NC.AskUser 
									    "Enter new link type"
										       " -- " NIL NIL 
										       MainWindow T)))
								 )
							 NC.UCASESystemLinkLabels))
					      T)
					    (T (NC.PrintMsg MainWindow T Choice 
							    " is a system reserved link type."
							    (CHARACTER 13)
							    "Please choose another link type."
							    (CHARACTER 13))
					       NIL)))
				   (OR Choice (SETQ Choice NC.UnspecifiedLinkLabel))
				   (AND (NOT (FMEMB Choice LinkLabels))
					(NC.PutLinkLabels PSA.Database (CONS Choice LinkLabels)))))
			       (COND
				 ((NULL Choice)
				   (RETURN))
				 ((NULL MultipleFlg)
				   (RETURN Choice))
				 ((EQ Choice (QUOTE --DONE--))
				   (RETURN LabelsList))
				 ((EQ Choice (QUOTE --ALL--))
				   (COND
				     (ReverseLinksFlg (NC.PrintMsg MainWindow NIL Choice ", ")
						      (SETQ LabelsList (UNION LabelsList LinkLabels)))
				     (T (RETURN LinkLabels))))
				 ((EQ Choice (QUOTE --←ALL--))
				   (NC.PrintMsg MainWindow NIL Choice ", ")
				   (SETQ LabelsList (UNION LabelsList (for Link in LinkLabels
									 collect (PACK* (QUOTE ←)
											Link)))))
				 ((AND (EQ Choice NC.UnspecifiedLinkLabel)
				       (FMEMB Choice LabelsList)))
				 (Choice (NC.PrintMsg MainWindow NIL Choice ", ")
					 (SETQ LabelsList (CONS Choice LabelsList)))))
			 (NC.ClearMsg MainWindow T))))))

(NC.AskNoteCardType
  (LAMBDA NIL                                                (* fgh: "23-Oct-84 15:01")
                                                             (* Ask user to choose a note card type)
    (PROG (W Z (Font (FONTCREATE (QUOTE HELVETICA)
				 10
				 (QUOTE BOLD))))
          (OR (AND (BOUNDP (QUOTE NC.NoteCardTypeMenu))
		   (type? MENU NC.NoteCardTypeMenu))
	      (SETQ NC.NoteCardTypeMenu (create MENU
						ITEMS ←(NC.ListOfCardTypes)
						CENTERFLG ← T
						TITLE ← "Type?"
						MENUFONT ← Font
						ITEMHEIGHT ←(IPLUS (FONTPROP Font (QUOTE HEIGHT))
								   1))))
          (SETQ Z (WINDOWPROP (WFROMMENU NC.MainMenu)
			      (QUOTE REGION)))
          (SETQ W (MENUITEMREGION (CAR (NTH (fetch (MENU ITEMS) of NC.MainMenu)
					    3))
				  NC.MainMenu))
          (replace MENUPOSITION of NC.NoteCardTypeMenu
	     with (CONS (IPLUS (fetch (REGION LEFT) of Z)
			       (fetch (REGION LEFT) of W))
			(IPLUS (fetch (REGION BOTTOM) of Z)
			       (fetch (REGION TOP) of W)
			       (IMINUS (fetch (MENU IMAGEHEIGHT) of NC.NoteCardTypeMenu)))))
          (RETURN (MENU NC.NoteCardTypeMenu)))))

(NC.ChooseTopLevelCard
  (LAMBDA NIL                                                (* rht: "16-Nov-84 10:24")

          (* Let the user choose one of the top level cards. Top level cards are specified by globalvar NC.TopLevelCards which
	  is a list of IDs)


    (PROG (ID Menu W Z)
          (SETQ Menu (create MENU
			     ITEMS ←(for CardID in NC.TopLevelCards collect (LIST (NC.RetrieveTitle
										    CardID 
										    PSA.Database)
										  CardID))
			     CENTERFLG ← T
			     MENUFONT ←(FONTCREATE (QUOTE HELVETICA)
						   10
						   (QUOTE BOLD))
			     WHENSELECTEDFN ←(FUNCTION (LAMBDA (Item Button Menu)
				 (NC.EditNoteCard (CADR Item))))
			     TITLE ← "FileBox?"))
          (SETQ W (MENUITEMREGION (CAR (NTH (fetch (MENU ITEMS) of NC.MainMenu)
					    4))
				  NC.MainMenu))
          (SETQ Z (WINDOWPROP (WFROMMENU NC.MainMenu)
			      (QUOTE REGION)))
          (replace (MENU MENUPOSITION) of Menu with (create POSITION
							    XCOORD ←(IPLUS (fetch (REGION LEFT)
									      of W)
									   (fetch (REGION LEFT)
									      of Z))
							    YCOORD ←(IPLUS
							      (fetch (REGION TOP) of W)
							      (fetch (REGION BOTTOM) of Z)
							      (IMINUS (fetch (MENU IMAGEHEIGHT)
									 of Menu)))))
          (SETQ ID (MENU Menu)))))

(NC.DisplayMainMenu
  (LAMBDA NIL                                                (* fgh: " 8-Aug-84 17:10")
                                                             (* Displays the main NoteCards menu)
    (PROG (W)
          (COND
	    ((SETQ W (WFROMMENU NC.MainMenu))
	      (WINDOWPROP W (QUOTE CLOSEFN)
			  NIL)
	      (DELETEMENU NC.MainMenu T)))
          (SETQ NC.MainMenuWindow (SETQ W (ADDMENU NC.MainMenu NIL (AND W (LOWERLEFT
									  (WINDOWPROP W (QUOTE REGION)
										      ))))))
          (WINDOWPROP W (QUOTE RESHAPEFN)
		      (QUOTE DON'T))
          (WINDOWPROP W (QUOTE SHRINKFN)
		      (QUOTE DON'T))
          (WINDOWPROP W (QUOTE CLOSEFN)
		      (FUNCTION (LAMBDA (Window)
			  (COND
			    (NC.FixedMenuFlg (QUOTE DON'T))
			    (T NIL)))))
          (WINDOWPROP W (QUOTE MOVEFN)
		      (FUNCTION (LAMBDA (Window)
			  (COND
			    (NC.FixedMenuFlg (QUOTE DON'T))
			    (T NIL))))))))

(NC.RemoveSketchMenuItems
  (LAMBDA (SketchMenu)                                       (* fgh: "13-Aug-84 18:40")

          (* * Remove unwanted items from Sketch Card SKetch Menu. Called from ADVISE on CREATE.SKETCHW.COMMANDMENU.
	  NOTE: SKETCHW refers to SK.INSURE.MENU)


    (PROG ((ItemsToBeRemoved (QUOTE (LINK New% View locator inspect))))
          (AND (NULL NC.AnnoFlg)
	       (SETQ ItemsToBeRemoved (CONS (QUOTE Annotate)
					    ItemsToBeRemoved)))
          (AND (NC.IDFromWindow SKETCHW)
	       (RETURN (replace (MENU ITEMS) of SketchMenu with (for Item in (fetch (MENU ITEMS)
										of SketchMenu)
								   when (NOT (FMEMB (CAR Item)
										    ItemsToBeRemoved))
								   collect Item)))))))

(NC.SelectionMenusWhenSelectedFn
  (LAMBDA (Item Menu Button)                                 (* fgh: " 7-May-84 19:16")
    (SELECTQ (CAR Item)
	     ((Done)
	       (SETQ NC.SelectionInProgress))
	     ((Abort Cancel)
	       (SETQ NC.SelectionInProgress)
	       (SETQ NC.SelectedCards))
	     (New% Card (SETQ NC.SelectedCards (CONS (QUOTE *New% Card*)
						     NC.SelectedCards)))
	     (NoSource (SETQ NC.SelectedCards (LIST (QUOTE NC00000)))
		       (SETQ NC.SelectionInProgress))
	     (NoBox (SETQ NC.SelectedCards (LIST NC.UnclassifiedID))
		    (SETQ NC.SelectionInProgress))
	     NIL)))

(NC.SetupTitleBarMenu
  (LAMBDA (Window ID NoteCardType)                           (* rht: " 4-Jan-85 12:04")
                                                             (* Setup the title bar menu for the window Window 
							     pertaining to Card specified by ID)

          (* * rht 1/3/85: Now takes optional NoteCardType arg in case need to override the ID's type.
	  Like when ID is of type that inherits from Browser. Also changed "pointer" to "link" everywhere.)


    (PROG NIL
          (OR NoteCardType (SETQ NoteCardType (NC.FetchType ID)))
          (OR (EQ (WINDOWPROP Window (QUOTE BUTTONEVENTFN))
		  (FUNCTION NC.TitleBarButtonEventFn))
	      (WINDOWPROP Window (QUOTE OLDBUTTONEVENTFN)
			  (WINDOWPROP Window (QUOTE BUTTONEVENTFN)
				      (FUNCTION NC.TitleBarButtonEventFn))))
          (WINDOWPROP
	    Window
	    (QUOTE TitleBarLeftButtonMenu)
	    (SELECTQ NoteCardType
		     ((Browser Graph)
		       (OR (AND (BOUNDP (QUOTE NC.GraphTitleBarMenu))
				(type? MENU NC.GraphTitleBarMenu))
			   (SETQ NC.GraphTitleBarMenu
			     (create MENU
				     ITEMS ←(QUOTE ((Show/Edit% Properties
						       (FUNCTION NC.EditProperties)
						       
					"Brings up an editor for the property list of this card."
						       (SUBITEMS (Edit% Property% List
								   (FUNCTION NC.EditProperties)
								   
					"Brings up an editor for the property list of this card.")
								 (Show% Links (FUNCTION 
										NC.ShowPointers)
									      
					   "Brings up a list of the links to and from this card.")))
						     (Title/Sources/FileBoxes
						       (FUNCTION (LAMBDA (TextStream)
							   (NC.AssignTitle TextStream)
							   (NC.AssignSources TextStream)
							   (NC.FileNoteCard TextStream)))
						       
		       "Do all of the operations necessary to file this note card in a file box."
						       (SUBITEMS (Assign% Title
								   (FUNCTION NC.AssignTitle)
								   
						       "Assigns a (new) title to this note card.")
								 (Designate% Sources
								   (FUNCTION NC.AssignSources)
								   
				       "Designate the source(s) of the information in this card.")
								 (File% in% FileBoxes
								   (FUNCTION NC.FileNoteCard)
								   
						 "File this note card in one or more file boxes.")
								 (Unfile% from% FileBoxes
								   (FUNCTION NC.UnfileNoteCard)
								   
					   "Remove this card from one or more of its file boxes.")
								 (Delete% Source
								   (FUNCTION NC.DeleteSource)
								   
							"Delete one of the sources of this card.")))
						     (Insert% Link (FUNCTION NC.AddLinkToGraphCard)
								   
						   "Add a node that points to another note card.")
						     (Close% and% Save
						       (FUNCTION CLOSEW)
						       
					  "Close this note card after saving it in the NoteFile."
						       (SUBITEMS (Close% and% Save
								   (FUNCTION CLOSEW)
								   
					  "Close this note card after saving it in the NoteFile.")
								 (Close% w/o% Saving
								   (FUNCTION NC.QuitWithoutSaving)
								   
		      "Close this note card without saving any changes made since the last Save.")
								 (Save% in% NoteFile
								   (FUNCTION NC.GraphCardSaveFn)
								   
				       "Save this card in the NoteFile but don't close the card.")
								 (Delete% Card
								   (FUNCTION NC.DeleteNoteCards)
								   
						"Permenantly delete this card from the NoteFile.")))))
				     CENTERFLG ← T
				     MENUFONT ←(FONTCREATE (QUOTE HELVETICA)
							   10
							   (QUOTE BOLD)))))
		       NC.GraphTitleBarMenu)
		     (Sketch (OR (AND (BOUNDP (QUOTE NC.SketchTitleBarMenu))
				      (type? MENU NC.SketchTitleBarMenu))
				 (SETQ NC.SketchTitleBarMenu
				   (create MENU
					   ITEMS ←(QUOTE
					     ((Show/Edit% Properties
						 (FUNCTION NC.EditProperties)
						 
					"Brings up an editor for the property list of this card."
						 (SUBITEMS (Edit% Property% List
							     (FUNCTION NC.EditProperties)
							     
					"Brings up an editor for the property list of this card.")
							   (Show% Links (FUNCTION NC.ShowPointers)
									
					   "Brings up a list of the links to and from this card.")))
					       (Title/Sources/FileBoxes
						 (FUNCTION (LAMBDA (TextStream)
						     (NC.AssignTitle TextStream)
						     (NC.AssignSources TextStream)
						     (NC.FileNoteCard TextStream)))
						 
		       "Do all of the operations necessary to file this note card in a file box."
						 (SUBITEMS (Assign% Title (FUNCTION NC.AssignTitle)
									  
						       "Assigns a (new) title to this note card.")
							   (Designate% Sources
							     (FUNCTION NC.AssignSources)
							     
				       "Designate the source(s) of the information in this card.")
							   (File% in% FileBoxes
							     (FUNCTION NC.FileNoteCard)
							     
						 "File this note card in one or more file boxes.")
							   (Unfile% from% FileBoxes
							     (FUNCTION NC.UnfileNoteCard)
							     
					   "Remove this card from one or more of its file boxes.")
							   (Delete% Source (FUNCTION NC.DeleteSource)
									   
							"Delete one of the sources of this card.")))
					       (Insert% Link (FUNCTION NC.AddLinkToSketchCard)
							     
						 "Add a link to another card to this sketch/map.")
					       (Close% and% Save
						 (FUNCTION CLOSEW)
						 
					  "Close this note card after saving it in the NoteFile."
						 (SUBITEMS (Close% and% Save (FUNCTION CLOSEW)
									     
					  "Close this note card after saving it in the NoteFile.")
							   (Close% w/o% Saving
							     (FUNCTION NC.QuitWithoutSaving)
							     
		      "Close this note card without saving any changes made since the last Save.")
							   (Save% in% NoteFile
							     (FUNCTION NC.SketchCardSaveFn)
							     
				       "Save this card in the NoteFile but don't close the card.")
							   (Delete% Card (FUNCTION NC.DeleteNoteCards)
									 
						"Permenantly delete this card from the NoteFile.")))))
					   CENTERFLG ← T
					   MENUFONT ←(FONTCREATE (QUOTE HELVETICA)
								 10
								 (QUOTE BOLD)))))
			     NC.SketchTitleBarMenu)
		     NIL))
          (COND
	    ((EQ NoteCardType (QUOTE Browser))
	      (WINDOWPROP Window (QUOTE TitleBarMiddleButtonMenu)
			  (OR (AND (BOUNDP (QUOTE NC.BrowserTitleBarMenu))
				   (type? MENU NC.BrowserTitleBarMenu)
				   NC.BrowserTitleBarMenu)
			      (SETQ NC.BrowserTitleBarMenu
				(create MENU
					ITEMS ←(QUOTE ((Recompute% Browser (FUNCTION 
									     NC.UpdateBrowserCard)
									   
			     "Recomputes this browser to show the current state of the NoteFile.")))
					CENTERFLG ← T
					MENUFONT ←(FONTCREATE (QUOTE HELVETICA)
							      10
							      (QUOTE BOLD)))))))))))

(NC.TitleBarButtonEventFn
  (LAMBDA (Window)                                           (* fgh: " 5-Oct-84 18:35")
                                                             (* if inside title region, bringup title menu, 
							     otherwise just call the oldbuttoneventfn)
    (PROG ((MiddleButtonMenu (WINDOWPROP Window (QUOTE TitleBarMiddleButtonMenu)))
	   LeftButtonMenu)
          (COND
	    ((OR (INSIDEP (DSPCLIPPINGREGION NIL Window)
			  (LASTMOUSEX Window)
			  (LASTMOUSEY Window))
		 (AND (NULL MiddleButtonMenu)
		      (LASTMOUSESTATE MIDDLE)))
	      (APPLY* (WINDOWPROP Window (QUOTE OLDBUTTONEVENTFN))
		      Window))
	    ((AND (LASTMOUSESTATE MIDDLE)
		  (type? MENU MiddleButtonMenu))
	      (APPLY* (OR (MENU MiddleButtonMenu)
			  (FUNCTION NILL))
		      Window))
	    (T (COND
		 ((SETQ LeftButtonMenu (WINDOWPROP Window (QUOTE TitleBarLeftButtonMenu)))
		   (APPLY* (OR (MENU LeftButtonMenu)
			       (FUNCTION NILL))
			   Window))))))))

(NC.ChooseCloseOrDelete
  (LAMBDA NIL                                                (* fgh: "29-Oct-84 00:05")

          (* * Asks the user whether a delete or close is desired an calls the appropriate function to do the work.)


    (PROG (Menu W Z (Font (FONTCREATE (QUOTE HELVETICA)
				      12
				      (QUOTE BOLD))))
          (SETQ Menu (OR (AND (BOUNDP (QUOTE NC.BrowseOrSearchMenu))
			      (type? MENU NC.BrowseOrSearchMenu)
			      NC.BrowseOrSearchMenu)
			 (SETQ NC.BrowseOrSearchMenu (create MENU
							     ITEMS ←(QUOTE (Close% Cards 
										    Delete% Cards))
							     MENUFONT ← Font
							     ITEMHEIGHT ←(IPLUS 2
										(FONTPROP
										  Font
										  (QUOTE HEIGHT)))
							     TITLE ← "Which?"))))
          (SETQ W (MENUITEMREGION (CAR (NTH (fetch (MENU ITEMS) of NC.MainMenu)
					    1))
				  NC.MainMenu))
          (SETQ Z (WINDOWPROP (WFROMMENU NC.MainMenu)
			      (QUOTE REGION)))
          (replace MENUPOSITION of Menu with (CONS (IPLUS (fetch (REGION LEFT) of W)
							  (fetch (REGION LEFT) of Z))
						   (IPLUS (fetch (REGION TOP) of W)
							  (fetch (REGION BOTTOM) of Z)
							  (IMINUS (fetch (MENU IMAGEHEIGHT)
								     of Menu)))))
          (RETURN (SELECTQ (MENU Menu)
			   (Close% Cards (NC.CloseNoteCards))
			   (Delete% Cards (NC.DeleteNoteCards NIL T))
			   NIL)))))
)
(* * Selection Mechanism)


(RPAQQ NC.SelectionInProgress NIL)
(DEFINEQ

(NC.SelectNoteCards
  (LAMBDA (SingleCardFlg SelectionPredicate Menu InstigatingIDorWindow ReturnLinksFlg)
                                                             (* rht: " 9-Jan-85 17:03")

          (* Select a set of note cards or a single note card, depending on SingleCardFlg. Works by interpreting all mouse 
	  presses until a card has been chosen (if SingleCardFlg is T) or until the Done button has been pressed 
	  (if SingleCardFlg is NIL). If the mouse press occus within a Title bar of a notecard, add that note card to the 
	  selected list. Otherwise, if you are pointing into a note card, call the BUTTONEVENTFN for that note card.
	  The Selection in Progress flag has been set, so all note card BUTTONEVENTFNs should know to ignore all presses 
	  except those that occur on link icons. Link icon presses should simply add the desination of that link to the 
	  selected note cards list.)



          (* * rht 8/1/84: Changed second RESETSAVE call to give NC.ClearMsg a NIL argument.)



          (* * rht 1/9/85: Fixed so now prints name of selected item even it's a link.)


    (PROG (Window ID ButtonEventFn (OldLength 0)
		  InstigatingWindow MenuWindow SelectedCard LinkOrID)
          (OR SelectionPredicate (SETQ SelectionPredicate (FUNCTION TRUE)))
          (SETQ NC.SelectedCards)
          (COND
	    ((NC.IDP InstigatingIDorWindow)
	      (SETQ InstigatingWindow (NC.FetchWindow InstigatingIDorWindow)))
	    ((WINDOWP InstigatingIDorWindow)
	      (SETQ InstigatingWindow InstigatingIDorWindow))
	    (T (SETQ InstigatingWindow NIL)))
          (RESETLST (RESETSAVE NIL (BQUOTE (NC.ClearMsg , InstigatingWindow)))
		    (RESETSAVE NC.SelectionInProgress (COND
				 (ReturnLinksFlg (QUOTE Links))
				 (T T)))
		    (RESETSAVE (ADDMENU Menu NIL (AND InstigatingWindow (create POSITION
										XCOORD ←(fetch
										  (REGION LEFT)
											   of
											    (
WINDOWREGION InstigatingWindow))
										YCOORD ←(fetch
										  (REGION TOP)
											   of
											    (
WINDOWREGION InstigatingWindow)))))
			       (LIST (QUOTE PROGN)
				     (LIST (QUOTE DETACHWINDOW)
					   (LIST (QUOTE WFROMMENU)
						 Menu))
				     (LIST (QUOTE DELETEMENU)
					   Menu T)))         (* If there is an instigating window, make sure it and 
							     all its attachments are visible on the screen.)
		    (COND
		      (InstigatingWindow (ATTACHWINDOW (WFROMMENU Menu)
						       InstigatingWindow
						       (QUOTE TOP)
						       (QUOTE LEFT))
					 (NC.MoveWindowOntoScreen InstigatingWindow)))
		    (NC.PrintMsg InstigatingWindow NIL "Items selected:  ")
		    (until (COND
			     (SingleCardFlg (OR NC.SelectedCards (NULL NC.SelectionInProgress)))
			     (T (NULL NC.SelectionInProgress)))
		       do (until (MOUSESTATE LEFT))
			  (SETQ Window (WHICHW LASTMOUSEX LASTMOUSEY))
			  (AND Window (SETQ ID (NC.IDFromWindow Window)))
			  (COND
			    (Window (SETQ ButtonEventFn (WINDOWPROP Window (QUOTE BUTTONEVENTFN)))
				    (COND
				      ((AND (NOT (INSIDEP (DSPCLIPPINGREGION NIL (WINDOWPROP
									       Window
									       (QUOTE DSP)))
							  (LASTMOUSEX Window)
							  (LASTMOUSEY Window))))
					(AND ID (NOT (FMEMB ID NC.SelectedCards))
					     (SETQ NC.SelectedCards (CONS ID NC.SelectedCards))))
				      (T (AND ButtonEventFn (APPLY* ButtonEventFn Window))))))
			  (COND
			    ((IGREATERP (LENGTH NC.SelectedCards)
					OldLength)
			      (COND
				((NULL (APPLY* SelectionPredicate (CAR NC.SelectedCards)))
				  (SETQ NC.SelectedCards (CDR NC.SelectedCards)))
				(T (SETQ OldLength (LENGTH NC.SelectedCards))
				   (NC.PrintMsg InstigatingWindow NIL
						(NC.FetchTitle (if (LISTP (SETQ LinkOrID
									    (CAR NC.SelectedCards)))
								   then (fetch (NOTECARDLINK SOURCEID)
									   of LinkOrID)
								 else LinkOrID))
						",  ")))))
			  (UNTILMOUSESTATE UP)
			  (TOTOPW (WFROMMENU Menu)))         (* Allow TEdit to finish any outstanding Selections 
							     caused by buttoning off of the Notecard link objects)
		    (BLOCK))
          (UNTILMOUSESTATE UP)
          (RETURN (PROG1 (COND
			   (SingleCardFlg (CAR NC.SelectedCards))
			   (T (DREVERSE NC.SelectedCards)))
			 (SETQ NC.SelectedCards))))))
)
(* * Fix up Lisp)


(PUTPROPS LOGOUT READVICE (NIL (BEFORE NIL (NC.LogoutAdvice))))
(READVISE LOGOUT)
(* * Set the modification date)


(RPAQQ NC.SystemDate "10-Jan-85 00:52:42")
(PUTPROPS NCINTERFACE COPYRIGHT ("Xerox Corporation" 1984 1985))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (2863 34850 (NC.MakeMainMenu 2873 . 10563) (NC.SetupScreen 10565 . 11606) (
NC.MainMenuWhenSelectedFn 11608 . 13239) (NC.CacheTitles 13241 . 14384) (NC.CacheTypesAndTitles 14386
 . 15655) (NC.CloseDatabaseFile 15657 . 18508) (NC.CompactDatabase 18510 . 19598) (
NC.DatabaseOperations 19600 . 22490) (NC.LogoutAdvice 22492 . 23287) (NC.DatabaseFileName 23289 . 
24444) (NC.DeleteDatabaseFile 24446 . 26689) (INSTALL 26691 . 29313) (NC.ForceDatabaseClose 29315 . 
29622) (NC.ListDatabaseFiles 29624 . 30584) (NC.MakeFloppies 30586 . 31286) (NC.MakeSysout 31288 . 
33056) (NC.AdjustCloseF 33058 . 33512) (NC.AdvisedCloseF 33514 . 33822) (NC.CloseNoteCards 33824 . 
34848)) (34882 54032 (NC.AskLinkLabel 34892 . 38832) (NC.AskNoteCardType 38834 . 40163) (
NC.ChooseTopLevelCard 40165 . 41663) (NC.DisplayMainMenu 41665 . 42721) (NC.RemoveSketchMenuItems 
42723 . 43558) (NC.SelectionMenusWhenSelectedFn 43560 . 44230) (NC.SetupTitleBarMenu 44232 . 51362) (
NC.TitleBarButtonEventFn 51364 . 52461) (NC.ChooseCloseOrDelete 52463 . 54030)) (54105 58828 (
NC.SelectNoteCards 54115 . 58826)))))
STOP