(FILECREATED "23-May-85 14:38:58" {PHYLUM}<NOTECARDS>RELEASE1.2>NCINTERFACE.;30 70762  

      changes to:  (FNS NC.SelectionMenusWhenSelectedFn NC.SelectNoteCards NC.ListDatabaseFiles)

      previous date: "22-May-85 16:40:52" {PHYLUM}<NOTECARDS>RELEASE1.2>NCINTERFACE.;29)


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

(PRETTYCOMPRINT NCINTERFACECOMS)

(RPAQQ NCINTERFACECOMS ((E (SETQ NC.SystemDate (DATE))
			   (UNMARKASCHANGED (QUOTE NC.SystemDate)
					    (QUOTE VARS)))
	(VARS NC.SystemDate)
	(P (UNMARKASCHANGED (QUOTE NC.SystemDate)
			    (QUOTE VARS)))
	(* * Internal variables)
	(GLOBALVARS NC.SelectionInProgress NC.SelectedCards NC.MainMenu NC.SelectingSourcesMenu 
		    NC.SelectingContentsMenu NC.SelectingSingleCardMenu NC.SelectingMultipleCardsMenu 
		    NC.DeleteSelectingMenu NC.SelectingParentsMenu NC.SelectingBrowserSourceMenu 
		    NC.SelectingFileBoxChildrenMenu NC.SelectingCardsMenu NC.SelectingCardMenu 
		    NC.TEditMenus NC.NoteCardTypeMenu NC.DatabaseOperationsMenu NC.LinkLabelMenu 
		    NC.TopLevelCards NC.MainMenuInProgress NC.WindowRightButtonMenu 
		    NC.StructEditTitleBarMenu NC.SketchTitleBarMenu NC.BrowserTitleBarMenu 
		    NC.BrowserTitleBarMiddleButtonMenu NC.GraphTitleBarMenu 
		    NC.GraphTitleBarMiddleButtonMenu NC.MainMenuWindow NC.LogoWindow LOGOW ExecWindow 
		    PROCESS.STATUS.WINDOW QUADTREE.HIGHRES NC.BrowseOrSearchMenu FONTDIRECTORIES 
		    NC.DatabaseFileNameSuggestion PSA.Database NC.UncachingNotCompleted 
		    NC.UnspecifiedLinkLabel NC.UCASESystemLinkLabels NC.UnclassifiedID)
	(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)
	      (NC.TEditMenus 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)))

(RPAQQ NC.SystemDate "23-May-85 14:39:01")
(UNMARKASCHANGED (QUOTE NC.SystemDate)
		 (QUOTE VARS))
(* * Internal variables)

(DECLARE: DOEVAL@COMPILE DONTCOPY

(GLOBALVARS NC.SelectionInProgress NC.SelectedCards NC.MainMenu NC.SelectingSourcesMenu 
	    NC.SelectingContentsMenu NC.SelectingSingleCardMenu NC.SelectingMultipleCardsMenu 
	    NC.DeleteSelectingMenu NC.SelectingParentsMenu NC.SelectingBrowserSourceMenu 
	    NC.SelectingFileBoxChildrenMenu NC.SelectingCardsMenu NC.SelectingCardMenu NC.TEditMenus 
	    NC.NoteCardTypeMenu NC.DatabaseOperationsMenu NC.LinkLabelMenu NC.TopLevelCards 
	    NC.MainMenuInProgress NC.WindowRightButtonMenu NC.StructEditTitleBarMenu 
	    NC.SketchTitleBarMenu NC.BrowserTitleBarMenu NC.BrowserTitleBarMiddleButtonMenu 
	    NC.GraphTitleBarMenu NC.GraphTitleBarMiddleButtonMenu NC.MainMenuWindow NC.LogoWindow 
	    LOGOW ExecWindow PROCESS.STATUS.WINDOW QUADTREE.HIGHRES NC.BrowseOrSearchMenu 
	    FONTDIRECTORIES NC.DatabaseFileNameSuggestion PSA.Database NC.UncachingNotCompleted 
	    NC.UnspecifiedLinkLabel NC.UCASESystemLinkLabels NC.UnclassifiedID)
)

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

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

(DEFINEQ

(NC.MakeMainMenu
  (LAMBDA (DatabaseTitle)                                    (* rht: "15-Feb-85 18:34")

          (* * Create the NoteCards menus)



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



          (* * rht 2/4/85: The browser source menu now accepts multiple selections.)


    (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.")
					  (Undo NIL "Backup over last selection.")
					  (Done NIL "Indicates that selection is completed.")))
			  WHENSELECTEDFN ←(FUNCTION NC.SelectionMenusWhenSelectedFn)
			  TITLE ← "Selecting Source(s)"
			  CENTERFLG ← T
			  MENUBORDERSIZE ← 1
			  MENUOUTLINESIZE ← 1
			  MENUCOLUMNS ← 3
			  MENUFONT ← Font
			  ITEMHEIGHT ←(IPLUS 10 (FONTPROP Font (QUOTE HEIGHT)))
			  MENUPOSITION ← Position
			  MENUTITLEFONT ← TitleFont))
          (SETQ NC.SelectingSourcesMenu X)
          (SETQ X (create MENU
			  ITEMS ←(QUOTE ((NoBox NIL "File in ToBeFiled box.")
					  (Undo NIL "Backup over last selection.")
					  (Done NIL "Indicates that selection is completed.")))
			  WHENSELECTEDFN ←(FUNCTION NC.SelectionMenusWhenSelectedFn)
			  TITLE ← "Selecting File Box(es)"
			  CENTERFLG ← T
			  MENUBORDERSIZE ← 1
			  MENUOUTLINESIZE ← 1
			  MENUCOLUMNS ← 3
			  MENUFONT ← Font
			  ITEMHEIGHT ←(IPLUS 10 (FONTPROP Font (QUOTE HEIGHT)))
			  MENUPOSITION ← Position
			  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
			  MENUTITLEFONT ← TitleFont))
          (SETQ NC.SelectingSingleCardMenu X)
          (SETQ X (create MENU
			  ITEMS ←(QUOTE ((Cancel NIL "Cancel this selection.")))
			  WHENSELECTEDFN ←(FUNCTION NC.SelectionMenusWhenSelectedFn)
			  TITLE ← "Selecting Single Card"
			  CENTERFLG ← T
			  MENUBORDERSIZE ← 1
			  MENUOUTLINESIZE ← 1
			  MENUCOLUMNS ← 1
			  MENUFONT ← Font
			  ITEMHEIGHT ←(IPLUS 10 (FONTPROP Font (QUOTE HEIGHT)))
			  MENUPOSITION ← Position
			  MENUTITLEFONT ← TitleFont))
          (SETQ NC.SelectingCardMenu X)
          (SETQ X (create MENU
			  ITEMS ←(QUOTE ((Cancel NIL "Cancel this selection.")
					  (Undo NIL "Backup over last selection.")
					  (Done NIL "Indicates that selection is completed.")))
			  WHENSELECTEDFN ←(FUNCTION NC.SelectionMenusWhenSelectedFn)
			  TITLE ← "Selecting Note Cards"
			  CENTERFLG ← T
			  MENUBORDERSIZE ← 1
			  MENUOUTLINESIZE ← 1
			  MENUCOLUMNS ← 3
			  MENUFONT ← Font
			  ITEMHEIGHT ←(IPLUS 10 (FONTPROP Font (QUOTE HEIGHT)))
			  MENUPOSITION ← Position
			  MENUTITLEFONT ← TitleFont))
          (SETQ NC.SelectingMultipleCardsMenu X)
          (SETQ X (create MENU
			  ITEMS ←(QUOTE ((Cancel NIL "Cancel this selection.")
					  (Undo NIL "Backup over last selection.")
					  (Done NIL "Indicates that selection is completed.")))
			  WHENSELECTEDFN ←(FUNCTION NC.SelectionMenusWhenSelectedFn)
			  TITLE ← "Selecting cards to close or delete"
			  CENTERFLG ← T
			  MENUBORDERSIZE ← 1
			  MENUOUTLINESIZE ← 1
			  MENUCOLUMNS ← 3
			  MENUFONT ← Font
			  ITEMHEIGHT ←(IPLUS 10 (FONTPROP Font (QUOTE HEIGHT)))
			  MENUPOSITION ← Position
			  MENUTITLEFONT ← TitleFont))
          (SETQ NC.DeleteSelectingMenu X)
          (SETQ X (create MENU
			  ITEMS ←(QUOTE ((Cancel NIL "Cancel this selection.")
					  (Undo NIL "Backup over last selection.")
					  (Done NIL "Indicates that selection is completed.")))
			  WHENSELECTEDFN ←(FUNCTION NC.SelectionMenusWhenSelectedFn)
			  TITLE ← "Selecting FileBox(s)"
			  CENTERFLG ← T
			  MENUBORDERSIZE ← 1
			  MENUOUTLINESIZE ← 1
			  MENUCOLUMNS ← 3
			  MENUFONT ← Font
			  ITEMHEIGHT ←(IPLUS 10 (FONTPROP Font (QUOTE HEIGHT)))
			  MENUPOSITION ← Position
			  MENUTITLEFONT ← TitleFont))
          (SETQ NC.SelectingParentsMenu X)
          (SETQ X (create MENU
			  ITEMS ←(QUOTE ((Cancel NIL "Cancel this selection.")
					  (Undo NIL "Backup over last selection.")
					  (Done NIL "Indicates that this operation is completed.")))
			  WHENSELECTEDFN ←(FUNCTION NC.SelectionMenusWhenSelectedFn)
			  TITLE ← "Selecting Root Card(s)/Box(s)"
			  CENTERFLG ← T
			  MENUBORDERSIZE ← 1
			  MENUOUTLINESIZE ← 1
			  MENUCOLUMNS ← 3
			  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.")
					  (Undo NIL "Backup over last selection.")
					  (Done NIL "Indicates that this operation is completed.")))
			  WHENSELECTEDFN ←(FUNCTION NC.SelectionMenusWhenSelectedFn)
			  TITLE ← "Selecting child cards"
			  CENTERFLG ← T
			  MENUBORDERSIZE ← 1
			  MENUOUTLINESIZE ← 1
			  MENUCOLUMNS ← 3
			  MENUFONT ← Font
			  ITEMHEIGHT ←(IPLUS 10 (FONTPROP Font (QUOTE HEIGHT)))
			  MENUPOSITION ← Position
			  MENUTITLEFONT ← TitleFont))
          (SETQ NC.SelectingFileBoxChildrenMenu X)
          (SETQ X (create MENU
			  ITEMS ←(QUOTE ((Cancel NIL "Cancel this operation.")
					  (Undo NIL "Backup over last selection.")
					  (Done NIL "Indicates that this operation is completed.")))
			  WHENSELECTEDFN ←(FUNCTION NC.SelectionMenusWhenSelectedFn)
			  TITLE ← "Selecting Cards"
			  CENTERFLG ← T
			  MENUBORDERSIZE ← 1
			  MENUOUTLINESIZE ← 1
			  MENUCOLUMNS ← 3
			  MENUFONT ← Font
			  ITEMHEIGHT ←(IPLUS 10 (FONTPROP Font (QUOTE HEIGHT)))
			  MENUPOSITION ← Position
			  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)                                 (* rht: "15-Feb-85 16:47")
                                                             (* 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 (COND
						((EQ Button (QUOTE LEFT))
						  (NC.CloseNoteCards))
						(T (NC.ChooseCloseOrDelete))))
				(NoteFile% Ops (NC.DatabaseOperations))
				NIL)))))
      (T (NC.PrintMsg NIL NIL (CHARACTER 13)
		      NC.MainMenuInProgress " in progress.  Please wait.")))))

(NC.CacheTitles
  (LAMBDA (DatabaseStream UncacheFlg QuietFlg OperationMsg)
                                                             (* rht: " 5-Feb-85 23:34")
                                                             (* Cache or uncache all of the titles on DatabaseSteam 
							     onto the prop lists of the NoteCard IDs)
    (PROG (CardTotal Title ID)
          (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)
                                                             (* rht: "28-Mar-85 11:49")
                                                             (* Cache or uncache all of the titles on DatabaseSteam 
							     onto the prop lists of the NoteCard IDs)
    (PROG (CardTotal Pair ID)
          (for CardNumber from 1 to (SETQ CardTotal (SUB1 (STREAMPROP DatabaseStream (QUOTE 
										      NCNEXTIDNUM))))
	     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: "13-Feb-85 19:16")
                                                             (* 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.)



          (* * rht 1/31/85: Added call to checkpoint database. That in turn dumps the next nodeID and next linkID.)


    (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)
				       (bind (Process ←(WINDOWPROP Window (QUOTE PROCESS)))
					  until (OR (NULL Process)
						    (PROCESS.FINISHEDP Process))
					  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.CheckpointDatabase PSA.Database)
	       (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."))))))

(NC.CompactDatabase
  (LAMBDA (FromFileName ToFileName)                          (* rht: " 1-Mar-85 19:29")
                                                             (* Top-level call to the database compactor.)

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



          (* * rht 3/1/85: New arg. compacts from FromFileName to ToFileName. If either is nil, then asks user.)


    (PROG (Result)
          (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 compacted."
			   (CHARACTER 13)))
	    ((AND (OR FromFileName (SETQ FromFileName (NC.DatabaseFileName 
							      "Name of NoteFile to be compacted:"
									   " -- " T)))
		  (OR ToFileName (SETQ ToFileName (NC.DatabaseFileName 
								  "Name of target of compaction:"
								       " -- " T))))
	      (NC.ClearMsg)
	      (COND
		((SETQ Result (NC.FastCompactDatabase FromFileName ToFileName))
		  (NC.PrintMsg NIL T (CAR Result)
			       " compacted to "
			       (CADR Result)
			       "."
			       (CHARACTER 13))
		  (SETQ NC.DatabaseFileNameSuggestion (PACKFILENAME (QUOTE VERSION)
								    NIL
								    (QUOTE BODY)
								    (CADR Result))))))))))

(NC.DatabaseOperations
  (LAMBDA NIL                                                (* rht: "20-Mar-85 11:21")
                                                             (* 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.")
						   (Checkpoint% Session (NC.CheckpointDatabase)
									
				    "Checkpoint the currently open NoteFile, saving dirty cards.")
						   (Abort% Session (NC.AbortSession)
								   
				  "Aborts the current session losing work since last checkpoint.")
						   (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 to a target file."
								      (SUBITEMS (
Compact% To% Target% File (NC.CompactDatabase)
			  "Compacts a NoteFile to a target file.")
										(Compact% In% Place
										  (
NC.CompactDatabaseInPlace)
										  
								  "Compacts a NoteFile in place.")))
						   (Repair% NoteFile (NC.ScavengeDatabaseFile NIL T)
								     
							      "Repairs an inconsistent NoteFile.")
						   (Delete% NoteFile (NC.DeleteDatabaseFile NIL)
								     
						      "Deletes the oldest version of a NoteFile.")
						   (Copy% NoteFile (NC.CopyDatabase)
								   
							    "Copies a notefile to a target file.")))
				   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)                                         (* rht: "17-Mar-85 16:44")
                                                             (* Delete file FileName)
    (PROG (FullFileName)                                     (* Make sure no open databases)

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



          (* * rht 3/17/85: Fixed for case when user specifies version number of file to delete.)


          (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 (if (FILENAMEFIELD FileName (QUOTE VERSION))
				 then (FULLNAME FileName)
			       else (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-Feb-85 13:45")

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



          (* * rht 1/10/85: Note new kludgey call to \UPDATEOF recommended by Tayloe to avoid truncation problems.)



          (* * rht 2/5/85: Added resetting of NC.UncachingNotCompleted here so it will happen after compact, repair, etc.)


    (\UPDATEOF DatabaseStream)
    (SETQ PSA.Database NIL)
    (SETQ NC.UncachingNotCompleted NIL)
    (CLOSEF DatabaseStream)))

(NC.ListDatabaseFiles
  (LAMBDA NIL                                                (* rht: "23-May-85 13:21")
                                                             (* Do a DIR on all of the NoteFiles on the current 
							     connected directory.)

          (* * rht 5/22/85: Now prompts user with search pattern based on current connected directory.)


    (PROG (Files SearchPattern)
          (RESETLST (RESETSAVE (TTYDISPLAYSTREAM PROMPTWINDOW))
		    (RESETSAVE NIL (LIST (QUOTE WINDOWPROP)
					 PROMPTWINDOW
					 (QUOTE PAGEFULLFN)
					 (WINDOWPROP PROMPTWINDOW (QUOTE PAGEFULLFN)
						     NIL)))
		    (GIVE.TTY.PROCESS PROMPTWINDOW)
		    (SETQ SearchPattern (NC.AskUser "Search pattern: " NIL (CONCAT (DIRECTORYNAME
										     T)
										   "*.NoteFile")
						    T NIL))
		    (CLEARBUF T)
		    (NC.PrintMsg NIL T "Searching ...")
		    (if (AND SearchPattern (SETQ Files (FILDIR SearchPattern)))
			then (NC.ClearMsg NIL)
			     (for File in Files do (printout PROMPTWINDOW File T))
		      else (NC.PrintMsg NIL T "There are no files matching the pattern: " 
					SearchPattern))))))

(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)
                                                             (* rht: "15-Feb-85 16:03")

          (* * Close note acrds on the screen)


    (PROG (ID Cards Window)
          (SETQ Cards (OR CardTextStreamWindowOrID (NC.SelectNoteCards NIL NIL NC.DeleteSelectingMenu 
								       NIL NIL 
							  "Please select the cards to be closed.")))
          (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 
		      OldLinkLabels)                         (* rht: "14-Feb-85 20:30")
                                                             (* 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".)



          (* * rht 2/14/85: Added extra arg OldLinkLabels in the Multiple selection case to display previous choices.)


    (PROG (Menu Choice Choices LabelsList (LinkLabels (NC.RetrieveLinkLabels PSA.Database 
									     SystemLinksFlg))
		Position)
          (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)
		       (if MultipleFlg
			   then ""
			 else "Link types chosen: "))
          (SETQ Position (AND (WINDOWP MainWindow)
			      (create POSITION
				      XCOORD ←(fetch (REGION LEFT) of (WINDOWPROP MainWindow
										  (QUOTE REGION)))
				      YCOORD ←(fetch (REGION TOP) of (WINDOWREGION MainWindow)))))
          (if MultipleFlg
	      then (SETQ Choices (STYLESHEET (CREATE.STYLE
					       (QUOTE ITEMS)
					       (if ReverseLinksFlg
						   then (LIST (create MENU
								      ITEMS ← LinkLabels)
							      (create MENU
								      ITEMS ←(for Link in LinkLabels
										collect
										 (PACK* (QUOTE ←)
											Link))))
						 else (LIST (create MENU
								    ITEMS ← LinkLabels)))
					       (QUOTE NEED.NOT.FILL.IN)
					       (QUOTE MULTI)
					       (QUOTE POSITION)
					       Position
					       (QUOTE TITLE)
					       "Link Types?"
					       (QUOTE SELECTIONS)
					       (LIST (for Label in OldLinkLabels
							when (NEQ (NTHCHAR Label 1)
								  (QUOTE ←))
							collect Label)
						     (for Label in OldLinkLabels
							when (EQ (NTHCHAR Label 1)
								 (QUOTE ←))
							collect Label)))))
		   (NC.ClearMsg MainWindow T)
		   (RETURN (COND
			     ((NULL Choices)
			       NIL)
			     (ReverseLinksFlg (NCONC (CAR Choices)
						     (CADR Choices)))
			     (T (CAR Choices)))))
          (SETQ Menu (create MENU
			     TITLE ← "Link Type?"
			     ITEMS ←(NCONC (COND
					     (ReverseLinksFlg (for Link in LinkLabels
								 join (LIST Link (CONCAT "←" Link))))
					     (T (COPY LinkLabels)))
					   (AND NewLinkFlg (LIST (QUOTE --New% Link% Type--)))
					   (AND CancelOkayFlg (LIST (QUOTE **CANCEL**))))
			     MENUPOSITION ← Position
			     MENUCOLUMNS ←(AND ReverseLinksFlg 2)))
          (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)))))
          (NC.ClearMsg MainWindow T)
          (RETURN Choice))))

(NC.AskNoteCardType
  (LAMBDA (Region)                                           (* fgh: " 1-Apr-85 11:50")
                                                             (* Ask user to choose a note card type)

          (* * rht 1/12/85: Now takes an optional Region argument dictating where to place the NoteCardTypeMenu.
	  If NIL, then uses MainMenu.)


    (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 T)
						CENTERFLG ← T
						TITLE ← "Type?"
						MENUFONT ← Font
						ITEMHEIGHT ←(IPLUS (FONTPROP Font (QUOTE HEIGHT))
								   1))))
          (replace MENUPOSITION of NC.NoteCardTypeMenu
	     with (COND
		    (Region (CONS (fetch (REGION LEFT) of Region)
				  (IPLUS (fetch (REGION BOTTOM) of Region)
					 (fetch (REGION HEIGHT) of Region)
					 (IMINUS (fetch (MENU IMAGEHEIGHT) of NC.NoteCardTypeMenu)))))
		    (T (CONS (IPLUS (fetch (REGION LEFT) of (SETQ Z (WINDOWPROP (WFROMMENU 
										      NC.MainMenu)
										(QUOTE REGION))))
				    (fetch (REGION LEFT)
				       of (SETQ W (MENUITEMREGION (CAR (NTH (fetch (MENU ITEMS)
									       of NC.MainMenu)
									    3))
								  NC.MainMenu))))
			     (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)                                 (* rht: "23-May-85 13:01")

          (* * rht 2/15/85: Added handler for Undo.)


    (SELECTQ (CAR Item)
	     ((Done)
	       (SETQ NC.SelectionInProgress))
	     ((Abort Cancel)
	       (SETQ NC.SelectionInProgress)
	       (SETQ NC.SelectedCards (QUOTE CANCELLED)))
	     (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))
	     (Undo (SETQ NC.SelectedCards (CONS (QUOTE *Undo% Selection*)
						NC.SelectedCards)))
	     NIL)))

(NC.SetupTitleBarMenu
  (LAMBDA (Window ID NoteCardType)                           (* rht: "22-May-85 01:47")
                                                             (* 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.)



          (* * rht 1/12/85: Added menu for StructEdit type. Just the same except has no InsertLink operation.
	  This needs to be cleaned up and interfaced to Types mechanism.)



          (* * rht 1/15/85: Added "Relayout" item to the browser title bar middle button menu, and made graph and structedit 
	  cards contain only that item on their middle button menus.)



          (* * rht 5/22/85: Took out structedit and structeditbrowser junk.)


    (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
		     (Graph (OR (AND (BOUNDP (QUOTE NC.GraphTitleBarMenu))
				     (type? MENU NC.GraphTitleBarMenu))
				(SETQ NC.GraphTitleBarMenu
				  (create MENU
					  ITEMS ←(QUOTE
					    ((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."
							    (SUBITEMS (Insert% Link
									(FUNCTION 
									  NC.AddLinkToGraphCard)
									
						   "Add a node that points to another note card.")
								      (Add% Global% Link
									(FUNCTION 
									  NC.AddGlobalLinkToCard)
									
						    "Add a global link emanating from this card.")
								      (Add% Global% Links
									(FUNCTION 
									  NC.AddGlobalLinksToCard)
									
						     "Add global links emanating from this 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.CardSaveFn)
								    
				       "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)
		     (Browser (OR (AND (BOUNDP (QUOTE NC.BrowserTitleBarMenu))
				       (type? MENU NC.BrowserTitleBarMenu))
				  (SETQ NC.BrowserTitleBarMenu
				    (create MENU
					    ITEMS ←(QUOTE
					      ((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.")))
						(Add% Global% Link
						  (FUNCTION NC.AddGlobalLinkToCard)
						  "Add a global link emanating from this card."
						  (SUBITEMS (Add% Global% Link
							      (FUNCTION NC.AddGlobalLinkToCard)
							      
						    "Add a global link emanating from this card.")
							    (Add% Global% Links
							      (FUNCTION NC.AddGlobalLinksToCard)
							      
						     "Add global links emanating from this 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.CardSaveFn)
							      
				       "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.BrowserTitleBarMenu)
		     (Sketch (OR (AND (BOUNDP (QUOTE NC.SketchTitleBarMenu))
				      (type? MENU NC.SketchTitleBarMenu))
				 (SETQ NC.SketchTitleBarMenu
				   (create MENU
					   ITEMS ←(QUOTE
					     ((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."
							     (SUBITEMS (Insert% Link
									 (FUNCTION 
									   NC.AddLinkToSketchCard)
									 
						 "Add a link to another card to this sketch/map.")
								       (Add% Global% Link
									 (FUNCTION 
									   NC.AddGlobalLinkToCard)
									 
						    "Add a global link emanating from this card.")
								       (Add% Global% Links
									 (FUNCTION 
									  NC.AddGlobalLinksToCard)
									 
						     "Add global links emanating from this 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.CardSaveFn)
							     
				       "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.BrowserTitleBarMiddleButtonMenu))
				   (type? MENU NC.BrowserTitleBarMiddleButtonMenu)
				   NC.BrowserTitleBarMiddleButtonMenu)
			      (SETQ NC.BrowserTitleBarMiddleButtonMenu
				(create MENU
					ITEMS ←(QUOTE ((Recompute% Browser (FUNCTION 
									     NC.UpdateBrowserCard)
									   
			     "Recomputes this browser to show the current state of the NoteFile.")
							(Relayout% Graph (FUNCTION 
									   NC.RelayoutBrowserCard)
									 
						    "Re-layout the browser, but keep same nodes.")
							(Reconnect% Nodes (FUNCTION 
									 NC.ConnectNodesInBrowser)
									  
	   "Draw all possible links, from currently selected link types, between pairs of nodes.")
							(Unconnect% Nodes (FUNCTION 
								       NC.UnconnectNodesInBrowser)
									  
							       "Undraw all links in the browser.")
							(Expand% Browser% Node
							  (FUNCTION NC.ExpandBrowserNode)
							  
					      "Expand the graph under one node to a given depth.")
							(Graph% Edit% Menu (FUNCTION 
									     NC.GetGraphEditMenu)
									   
								"Bring up the graph editor menu.")
							(Change% Browser% Specs
							  (FUNCTION NC.ChangeBrowserSpecs)
							  
		 "Make changes to some or all of the browser specs, e.g. link types, depth, etc.")))
					CENTERFLG ← T
					MENUFONT ←(FONTCREATE (QUOTE HELVETICA)
							      10
							      (QUOTE BOLD)))))))
	    ((EQ NoteCardType (QUOTE Graph))
	      (WINDOWPROP Window (QUOTE TitleBarMiddleButtonMenu)
			  (OR (AND (BOUNDP (QUOTE NC.GraphTitleBarMiddleButtonMenu))
				   (type? MENU NC.GraphTitleBarMiddleButtonMenu)
				   NC.GraphTitleBarMiddleButtonMenu)
			      (SETQ NC.GraphTitleBarMiddleButtonMenu
				(create MENU
					ITEMS ←(QUOTE ((Relayout% Graph (FUNCTION 
									  NC.RelayoutGraphCard)
									
						      "Re-layout the graph, but keep same nodes.")))
					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 Msg 
			 CheckForCancelFlg)                  (* rht: "23-May-85 13:00")

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



          (* * rht 2/15/85: Now can backspace over last selection chosen. Added new arg Msg so that when we reprint the list, 
	  we can reprint the message as well.)



          (* * rht 3/23/85: Added the CheckForCancelFlg arg, which if non-nil causes Cancel to be handled differently then 
	  Done after no selections. Namely, Cancel will return the atom CANCELLED whereas Done with no selections returns NIL.
	  If CheckForCancelFlg is NIL then NIL is returned in both cases.)


    (PROG (Window WinRegion 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)))
          (SETQ WinRegion (WINDOWREGION (OR InstigatingWindow (WFROMMENU NC.MainMenu))))
          (NC.PrintMsg InstigatingWindow T (if Msg
					       then (CONCAT Msg (CHARACTER 13))
					     else "")
		       "Items selected:  ")
          (RESETLST (RESETSAVE NIL (BQUOTE (NC.ClearMsg , InstigatingWindow T)))
		    (RESETSAVE NC.SelectionInProgress (COND
				 (ReturnLinksFlg (QUOTE Links))
				 (T T)))
		    (RESETSAVE (ADDMENU Menu NIL (create POSITION
							 XCOORD ←(fetch (REGION LEFT) of WinRegion)
							 YCOORD ←(if InstigatingWindow
								     then (fetch (REGION TOP)
									     of WinRegion)
								   else (fetch (REGION BOTTOM)
									   of WinRegion))))
			       (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)))
		    (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
				((EQ (CAR NC.SelectedCards)
				     (QUOTE *Undo% Selection*))
                                                             (* Chop off two elements from the list -
							     the indicator and the previous item.)
				  (SETQ NC.SelectedCards (CDDR NC.SelectedCards))
				  (SETQ OldLength (LENGTH NC.SelectedCards))
                                                             (* Reprint the titles of the selections.)
				  (NC.PrintMsg InstigatingWindow T (if Msg
								       then (CONCAT Msg (CHARACTER
										      13))
								     else "")
					       "Items selected:  ")
				  (for LinkOrID in (REVERSE NC.SelectedCards)
				     do (NC.PrintMsg InstigatingWindow NIL
						     (NC.FetchTitle (if (type? NOTECARDLINK LinkOrID)
									then (fetch (NOTECARDLINK
										      SOURCEID)
										of LinkOrID)
								      else LinkOrID))
						     ",  ")))
				((NULL (APPLY* SelectionPredicate (CAR NC.SelectedCards)))
                                                             (* Selection was not valid.)
				  (SETQ NC.SelectedCards (CDR NC.SelectedCards)))
				(T                           (* A valid selection.)
				   (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
			   ((EQ NC.SelectedCards (QUOTE CANCELLED))
			     (if CheckForCancelFlg
				 then (QUOTE CANCELLED)
			       else NIL))
			   (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 "23-May-85 14:39:55")
(PUTPROPS NCINTERFACE COPYRIGHT ("Xerox Corporation" 1984 1985))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (4259 38171 (NC.MakeMainMenu 4269 . 12245) (NC.SetupScreen 12247 . 13288) (
NC.MainMenuWhenSelectedFn 13290 . 15002) (NC.CacheTitles 15004 . 16150) (NC.CacheTypesAndTitles 16152
 . 17435) (NC.CloseDatabaseFile 17437 . 20482) (NC.CompactDatabase 20484 . 21937) (
NC.DatabaseOperations 21939 . 25035) (NC.LogoutAdvice 25037 . 25832) (NC.DatabaseFileName 25834 . 
26989) (NC.DeleteDatabaseFile 26991 . 29454) (INSTALL 29456 . 32078) (NC.ForceDatabaseClose 32080 . 
32719) (NC.ListDatabaseFiles 32721 . 33976) (NC.MakeFloppies 33978 . 34678) (NC.MakeSysout 34680 . 
36448) (NC.AdjustCloseF 36450 . 36904) (NC.AdvisedCloseF 36906 . 37214) (NC.CloseNoteCards 37216 . 
38169)) (38203 63705 (NC.AskLinkLabel 38213 . 42357) (NC.AskNoteCardType 42359 . 44150) (
NC.ChooseTopLevelCard 44152 . 45650) (NC.DisplayMainMenu 45652 . 46708) (NC.RemoveSketchMenuItems 
46710 . 47545) (NC.SelectionMenusWhenSelectedFn 47547 . 48404) (NC.SetupTitleBarMenu 48406 . 61035) (
NC.TitleBarButtonEventFn 61037 . 62134) (NC.ChooseCloseOrDelete 62136 . 63703)) (63778 70478 (
NC.SelectNoteCards 63788 . 70476)))))
STOP