(FILECREATED "17-Dec-87 11:02:14" {QV}<NOTECARDS>1.3KNEXT>PMIPATCH066.;40 53108  

      changes to:  (FNS NCHist.HistoryCardMakeFn NCHist.CreateHistoryCardTitle 
			NCHist.HistoricizeNoteFile NCHist.PutMainCardDataDisplayFn 
			NCHist.PutTitleDisplayFn NCHist.CreateHistoryDate NCHist.ComputeHistory)
		   (VARS PMIPATCH066COMS)

      previous date: "16-Dec-87 12:07:32" {QV}<NOTECARDS>1.3KNEXT>PMIPATCH066.;39)


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

(PRETTYCOMPRINT PMIPATCH066COMS)

(RPAQQ PMIPATCH066COMS ((* * The coms for NCCOLLABORATION, NCCOLLABORATORCARD, and NCHISTORYCARD 
			     should be changed to use NC.LoadFileFromDirectories like this:)
	(DECLARE: COPY FIRST (P (NC.LoadFileFromDirectories (QUOTE NCCOLLABORATORCARD))
				(NC.LoadFileFromDirectories (QUOTE NCHISTORYCARD))
				(NC.LoadFileFromDirectories (QUOTE NCLOGGER))
				(NC.LoadFileFromDirectories (QUOTE PMIPATCH067))))
	(* * New for NCPROGINT)
	(FNS NCP.CoerceToInterestedWindow NCP.NewCardP NCP.NoteFileAddProp)
	(* * Changed in NCHISTORYCARD)
	(FNS NCHist.AddHistoryCard NCHist.HistoryCardMakeFn NCHist.HistoryCardWhenSavedFn 
	     NCHist.NoteFileWhenOpenedFn NCHist.HistoricizeNoteFile NCHist.CreateHistoryCardTitle)
	(* * New in NCHISTORYCARD)
	(RECORDS EventCategory)
	(GLOBALVARS NCHist.HistoryEventsSpecsStylesheet NCHist.HistoryEventHashArray 
		    NCHist.LogEventFnHashArray NCHist.HistoryLinkType NCHist.EventCategories 
		    NCHist.CardEvents NCHist.CreateLinkEvents NCHist.DeleteLinkEvents 
		    NCHist.BrowserEvents NCHist.CardTypeEvents)
	(VARS (NCHist.HistoryLinkType (QUOTE History))
	      (NCHist.HistoryEventHashArray (HASHARRAY NCLOG.HashArraySize))
	      (NCHist.LogEventFnHashArray (HASHARRAY NCLOG.HashArraySize))
	      (NCHist.CardEvents (create EventCategory Name ← (QUOTE Card% Events)
					 MenuItems ← (QUOTE (Create% Card Bring% Up% Card Close% Card 
									  Change% Card% Substance 
									 Change% Card% Prop% List 
									  Change% Card% Title 
									  Delete% Card))
					 MenuItemsFn ← NIL DefaultMenuItems ←
					 (QUOTE (Create% Card Change% Card% Substance 
							      Change% Card% Title Delete% Card))
					 DefaultMenuItemsFn ← NIL MenuChoicesFn ← NIL))
	      (NCHist.CreateLinkEvents (create EventCategory Name ← (QUOTE Create% Link% Events)
					       MenuItems ← NIL MenuItemsFn ← (FUNCTION 
							       NCHist.CreateLinkEventsMenuItemsFn)
					       DefaultMenuItems ← NIL DefaultMenuItemsFn ←
					       (FUNCTION NCHist.CreateLinkEventsDefaultMenuChoicesFn)
					       MenuChoicesFn ← (FUNCTION 
							     NCHist.CreateLinkEventsMenuChoicesFn)))
	      (NCHist.DeleteLinkEvents (create EventCategory Name ← (QUOTE Delete% Link% Events)
					       MenuItems ← NIL MenuItemsFn ← (FUNCTION 
							       NCHist.DeleteLinkEventsMenuItemsFn)
					       DefaultMenuItems ← NIL DefaultMenuItemsFn ←
					       (FUNCTION NCHist.DeleteLinkEventsDefaultMenuChoicesFn)
					       MenuChoicesFn ← (FUNCTION 
							     NCHist.DeleteLinkEventsMenuChoicesFn)))
	      (NCHist.BrowserEvents (create EventCategory Name ← (QUOTE Browser% Events)
					    MenuItems ← (QUOTE (Recompute% Browser Relayout% Browser))
					    MenuItemsFn ← NIL DefaultMenuItems ← (QUOTE (
Recompute% Browser))
					    DefaultMenuItemsFn ← NIL MenuChoicesFn ← NIL))
	      (NCHist.CardTypeEvents (create EventCategory Name ← (QUOTE Card% Type% Events)
					     MenuItems ← (QUOTE (Add% Card% Type))
					     MenuItemsFn ← NIL DefaultMenuItems ← NIL 
					     DefaultMenuItemsFn ← NIL MenuChoicesFn ← NIL))
	      (NCHist.EventCategories (LIST NCHist.CardEvents NCHist.CreateLinkEvents 
					    NCHist.DeleteLinkEvents NCHist.BrowserEvents 
					    NCHist.CardTypeEvents)))
	(* * General automated history card functions)
	(FNS NCHist.CreateHistoryDate NCHist.ComputeHistory NCHist.GetLogEventFromStream 
	     NCHist.ProcessLogEvent NCHist.ChangeHistoryEventSpecs NCHist.AskHistoryEventSpecs 
	     NCHist.InitializeHistoryEventsSpecsStylesheet NCHist.InitializeHistoryEventHashArray 
	     NCHist.InitializeLogEventFnHashArray NCHist.ConvertPointersToLinks NCHist.TurnLoggingOn 
	     NCHist.TurnLoggingOff)
	(* * Fns for the various event category functions)
	(FNS NCHist.CreateLinkEventsMenuItemsFn NCHist.CreateLinkEventsDefaultMenuChoicesFn 
	     NCHist.CreateLinkEventsMenuChoicesFn NCHist.DeleteLinkEventsMenuItemsFn 
	     NCHist.DeleteLinkEventsDefaultMenuChoicesFn NCHist.DeleteLinkEventsMenuChoicesFn)
	(* * Fns called to display the events in the History Card)
	(FNS NCHist.EditCard.BeginDisplayFn NCHist.EditCard.EndDisplayFn 
	     NCHist.QuitCard.BeginDisplayFn NCHist.QuitCard.EndDisplayFn 
	     NCHist.MakeCard.BeginDisplayFn NCHist.MakeCard.EndDisplayFn NCHist.GetNewCardDisplayFn 
	     NCHist.DelCardDisplayFn NCHist.CacheCardDisplayFn NCHist.UncacheCardDisplayFn 
	     NCHist.SaveCard.BeginDisplayFn NCHist.SaveCard.EndDisplayFn NCHist.PutLinksDisplayFn 
	     NCHist.PutMainCardDataDisplayFn NCHist.PutPropListDisplayFn NCHist.PutTitleDisplayFn 
	     NCHist.AssignTitle.BeginDisplayFn NCHist.AssignTitle.EndDisplayFn 
	     NCHist.MakeLinkDisplayFn NCHist.DelLinkDisplayFn NCHist.RecomputeBrowser.BeginDisplayFn 
	     NCHist.RecomputeBrowser.EndDisplayFn NCHist.RelayoutBrowser.BeginDisplayFn 
	     NCHist.RelayoutBrowser.EndDisplayFn NCHist.AddCardTypeDisplayFn 
	     NCHist.StartLoggingDisplayFn)
	(P (NCHist.InitializeHistoryEventsSpecsStylesheet)
	   (NCHist.InitializeHistoryEventHashArray)
	   (NCHist.InitializeLogEventFnHashArray))
	(* * Changed in NCCOLLABORATION)
	(FNS NCCollab.OpenNoteFileFn)
	(* * Add this expression to the end of the file coms for NCCOLLABORATION)
	(P (NCP.AddSessionIconMenuItem (QUOTE NoteFile)
				       (QUOTE (% Collaboratize%  NCCollab.CollaboratizeNoteFile 
								 "Collaboratizes a notefile.")))
	   (NCP.AddNoteFileIconMenuItem (QUOTE (Collaboratize NCCollab.CollaboratizeNoteFile 
							      "Collaboratizes a notefile."))
					(QUOTE Open)))
	(* * New for NCDATABASE)
	(FNS NC.NoteFileFromUID)
	(* * Install the altered History card type)
	(P (NCHist.AddHistoryCard))))
(* * The coms for NCCOLLABORATION, NCCOLLABORATORCARD, and NCHISTORYCARD should be changed to 
use NC.LoadFileFromDirectories like this:)

(DECLARE: COPY FIRST 
(NC.LoadFileFromDirectories (QUOTE NCCOLLABORATORCARD))
(NC.LoadFileFromDirectories (QUOTE NCHISTORYCARD))
(NC.LoadFileFromDirectories (QUOTE NCLOGGER))
(NC.LoadFileFromDirectories (QUOTE PMIPATCH067))
)
(* * New for NCPROGINT)

(DEFINEQ

(NCP.CoerceToInterestedWindow
  (LAMBDA (WinOrCardOrNoteFile)                              (* pmi: "21-Oct-87 15:56")

          (* * pmi 10/21/87: Created to give prog int users the ability to get a reasonable window from various inputs.)


    (NC.CoerceToInterestedWindow WinOrCardOrNoteFile)))

(NCP.NewCardP
  (LAMBDA (Card)                                             (* pmi: "21-Oct-87 15:54")

          (* * pmi 10/21/87: First created. Allows prog int users to tell if a card has been saved yet.)


    (NC.FetchNewCardFlg Card)))

(NCP.NoteFileAddProp
  (LAMBDA (NoteFile PROP NEWVALUE)                           (* pmi: "23-Oct-87 15:02")

          (* * Prog. int. way into NC.NoteFileAddProp.)


    (NC.NoteFileAddProp NoteFile PROP NEWVALUE)))
)
(* * Changed in NCHISTORYCARD)

(DEFINEQ

(NCHist.AddHistoryCard
  [LAMBDA NIL                                                (* edited: "15-Dec-87 10:44")

          (* * Add History card type to card type list)



          (* * pmi 10/22/87: Added left button items.)


    (NCP.CreateCardType (QUOTE History)
			  (QUOTE Text)
			  [BQUOTE ((MakeFn , (FUNCTION NCHist.HistoryCardMakeFn]
			  (BQUOTE ((DisplayedInMenuFlg T)
				     (LeftButtonMenuItems
				       ,
				       (APPEND (NC.GetCardTypeField LeftButtonMenuItems
								      (QUOTE Text))
						 (QUOTE (("----------" (FUNCTION NULL))
							    (Compute% History (FUNCTION 
									    NCHist.ComputeHistory)
									      
						  "Computes a history from the current log file.")
							    (Change% History% Event% Specs
							      (FUNCTION 
								NCHist.ChangeHistoryEventSpecs)
							      
						  "Change event specs used to compute a history.")
							    (Convert% Pointers% to% Links
							      (FUNCTION 
								NCHist.ConvertPointersToLinks)
							      
						      "Converts all pointer icons to real links."])

(NCHist.HistoryCardMakeFn
  (LAMBDA (Card Title NoDisplayFlg)                          (* pmi: "17-Dec-87 10:44")

          (* * pmi 10/29/87: Now turns on logging.)


    (DECLARE (GLOBALVARS NCHist.EventCategories))
    (LET ((NoteFile (NCP.CardNoteFile Card))
	  ReturnValue HistoryFileBox DateString)

          (* * If one doesn't exist, create a NoteFile use history filebox, otherwise find the old one.)


         (SETQ HistoryFileBox (NCHist.GetHistoryFileBox NoteFile))

          (* * Create a text card, then give it a title and file it)


         (SETQ ReturnValue (NCP.ApplySuperTypeFn MakeFn Card Title NoDisplayFlg))
                                                             (* Cache the history filebox so that NCP.FileCards 
							     won't have to close it.)
         (OR (NCP.CardCachedP HistoryFileBox)
	       (NCP.CacheCards HistoryFileBox))
         (NCP.FileCards Card HistoryFileBox)
         (NCP.CardTitle Card (OR Title (NCHist.CreateHistoryCardTitle Card)))
         (NC.NoteFileAddProp NoteFile (QUOTE HistoryCards)
			       Card)

          (* * Put the start time in the beginning of the card's substance in bold face.)


         (SETQ DateString (CONCAT (DATE (DATEFORMAT NO.DATE NO.SECONDS))
				      " - "))
         (NCP.CardAddText Card (CONCAT DateString (CHARACTER 13))
			    (QUOTE START))
         (TEDIT.LOOKS (NCP.CardSubstance Card)
			(QUOTE (WEIGHT BOLD))
			1
			(NCHARS DateString))               (* Turn on logging for automated History cards.)
         (NCP.CardUserDataProp Card (QUOTE NCLogInfo)
				 (NCLOG.StartLogging NoteFile))
         (NCP.CardUserDataProp Card (QUOTE HistoryEventSpecs)
				 (for EventCategory in NCHist.EventCategories
				    bind CategoryChoices DefaultMenuItemsFn MenuChoicesFn
				    collect (SETQ CategoryChoices (if (fetch (EventCategory
										       
										 DefaultMenuItems)
									       of EventCategory)
									elseif
									 (SETQ DefaultMenuItemsFn
									   (fetch (EventCategory
										      
									       DefaultMenuItemsFn)
									      of EventCategory))
									  then (APPLY* 
									       DefaultMenuItemsFn 
											 NoteFile)))
					      (if (SETQ MenuChoicesFn (fetch (EventCategory
										     MenuChoicesFn)
									     of EventCategory))
						  then (APPLY* MenuChoicesFn CategoryChoices Card 
								   NoteFile)
						else CategoryChoices)))
     ReturnValue)))

(NCHist.HistoryCardWhenSavedFn
  [LAMBDA (HistoryCard)                                      (* edited: "16-Dec-87 12:06")

          (* * QuitFn for the History card type. Delete old close time from the History card and insert the current close 
	  time in its place. Only do this for "current" history cards, i.e. ones opened during this session.)


    (if (for Card in (NCP.NoteFileProp (NCP.CardNoteFile HistoryCard)
					       (QUOTE HistoryCards))
	     when (NCP.ValidCardP Card) thereis (NCP.SameCardP Card HistoryCard))
	then (LET ((Stream (NCP.CardSubstance HistoryCard))
		     Time AfterDashPosition CRPosition)
		    [SETQ Time (CONCAT " " (DATE (DATEFORMAT NO.DATE NO.SECONDS]
		    (SETQ AfterDashPosition (ADD1 (TEDIT.FIND Stream "-" 1)))
		    (SETQ CRPosition (TEDIT.FIND Stream (CHARACTER 13)
						     1))
		    (TEDIT.DELETE Stream AfterDashPosition (IDIFFERENCE CRPosition 
									    AfterDashPosition))
		    (NCP.CardAddText HistoryCard Time AfterDashPosition)
		    (TEDIT.LOOKS (NCP.CardSubstance HistoryCard)
				   (QUOTE (WEIGHT BOLD))
				   AfterDashPosition
				   (NCHARS Time])

(NCHist.NoteFileWhenOpenedFn
  (LAMBDA (NoteFile)                                         (* pmi: "19-Nov-87 12:41")

          (* * Function to be called when we open a NoteFile that has been "Historitized." Creates and opens a new History 
	  card for this session)



          (* * rht 2/4/87: Now calls NCP.CreateCard with NoDisplayFlg NIL.)



          (* * pmi 10/22/87: Now places new History card at (0, 0) if NCHist.HistoryCardPosition is not set.)


    (DECLARE (GLOBALVARS NCHist.HistoryCardPosition))
    (LET (HistoryCard)
         (NCHist.GetHistoryFileBox NoteFile)
         (NCP.OpenCard (SETQ HistoryCard (NCP.CreateCard (QUOTE History)
							       NoteFile NIL T))
			 (OR NCHist.HistoryCardPosition
			       (SETQ NCHist.HistoryCardPosition
				 (create POSITION
					   XCOORD ← 0
					   YCOORD ← 0)))))))

(NCHist.HistoricizeNoteFile
  (LAMBDA (NoteFile)                                         (* rht: "29-Jun-87 17:03")

          (* * Initialize given notefile for History Card use. Make a History Use Filebox if none exists and register in the 
	  notefile. Hang a call to NCHist.NoteFileWhenOpenedFn in the OpenEventsCard for the notefile.)



          (* * rht 4/19/87: Now calls NC.LoadFileFromDirectories rather than FILESLOAD.)


    (if (NCP.OpenNoteFileP NoteFile)
	then (LET ((OpenEventSExp (QUOTE (PROGN (NC.LoadFileFromDirectories (QUOTE 
										    NCHISTORYCARD))
						      (NCHist.NoteFileWhenOpenedFn NoteFile))))
		     (OpenEventsCard (NCP.GetOpenEventsCard NoteFile))
		     OpenEventsCardWasCachedFlg)

          (* * Add call to NCHist.NoteFileWhenOpenedFn to the open events card substance.)


		    (if (NOT (SETQ OpenEventsCardWasCachedFlg (NCP.ActiveCardP OpenEventsCard)
				   ))
			then (NCP.CacheCards OpenEventsCard))
		    (if (NOT (MEMBER OpenEventSExp (NCP.CardSubstance OpenEventsCard)))
			then (NCP.CardSubstance OpenEventsCard (CONS OpenEventSExp
									   (NCP.CardSubstance
									     OpenEventsCard))))
		    (if (NOT OpenEventsCardWasCachedFlg)
			then (NCP.CloseCards OpenEventsCard))

          (* * Run the history OpenNoteFileFn now.)


		    (NCHist.NoteFileWhenOpenedFn NoteFile))
      else (NCP.ReportError "NCHist.HistoritizeNoteFile" (CONCAT 
							    "Can't historitize closed notefile: "
								       NoteFile)))))

(NCHist.CreateHistoryCardTitle
  (LAMBDA (Card)                                             (* pmi: "14-Dec-87 12:06")

          (* * Creates title for history card consisting of date and initials.)


    (CONCAT (NCHist.CreateHistoryDate)
	      " "
	      (NCP.NoteFileProp (NCP.CardNoteFile Card)
				  (QUOTE Initials)))))
)
(* * New in NCHISTORYCARD)

[DECLARE: EVAL@COMPILE 

(DATATYPE EventCategory (Name MenuItems MenuItemsFn DefaultMenuItems DefaultMenuItemsFn 
				MenuChoicesFn))
]
(/DECLAREDATATYPE (QUOTE EventCategory)
		  (QUOTE (POINTER POINTER POINTER POINTER POINTER POINTER))
		  (QUOTE ((EventCategory 0 POINTER)
			  (EventCategory 2 POINTER)
			  (EventCategory 4 POINTER)
			  (EventCategory 6 POINTER)
			  (EventCategory 8 POINTER)
			  (EventCategory 10 POINTER)))
		  (QUOTE 12))
(DECLARE: DOEVAL@COMPILE DONTCOPY

(GLOBALVARS NCHist.HistoryEventsSpecsStylesheet NCHist.HistoryEventHashArray 
	    NCHist.LogEventFnHashArray NCHist.HistoryLinkType NCHist.EventCategories 
	    NCHist.CardEvents NCHist.CreateLinkEvents NCHist.DeleteLinkEvents NCHist.BrowserEvents 
	    NCHist.CardTypeEvents)
)

(RPAQQ NCHist.HistoryLinkType History)

(RPAQ NCHist.HistoryEventHashArray (HASHARRAY NCLOG.HashArraySize))

(RPAQ NCHist.LogEventFnHashArray (HASHARRAY NCLOG.HashArraySize))

(RPAQ NCHist.CardEvents (create EventCategory Name ← (QUOTE Card% Events)
				  MenuItems ← (QUOTE (Create% Card Bring% Up% Card Close% Card 
								   Change% Card% Substance 
								   Change% Card% Prop% List 
								   Change% Card% Title Delete% Card))
				  MenuItemsFn ← NIL DefaultMenuItems ← (QUOTE (Create% Card 
									  Change% Card% Substance 
									      Change% Card% Title 
										     Delete% Card))
				  DefaultMenuItemsFn ← NIL MenuChoicesFn ← NIL))

(RPAQ NCHist.CreateLinkEvents (create EventCategory Name ← (QUOTE Create% Link% Events)
					MenuItems ← NIL MenuItemsFn ← (FUNCTION 
							       NCHist.CreateLinkEventsMenuItemsFn)
					DefaultMenuItems ← NIL DefaultMenuItemsFn ←
					(FUNCTION NCHist.CreateLinkEventsDefaultMenuChoicesFn)
					MenuChoicesFn ← (FUNCTION 
							     NCHist.CreateLinkEventsMenuChoicesFn)))

(RPAQ NCHist.DeleteLinkEvents (create EventCategory Name ← (QUOTE Delete% Link% Events)
					MenuItems ← NIL MenuItemsFn ← (FUNCTION 
							       NCHist.DeleteLinkEventsMenuItemsFn)
					DefaultMenuItems ← NIL DefaultMenuItemsFn ←
					(FUNCTION NCHist.DeleteLinkEventsDefaultMenuChoicesFn)
					MenuChoicesFn ← (FUNCTION 
							     NCHist.DeleteLinkEventsMenuChoicesFn)))

(RPAQ NCHist.BrowserEvents (create EventCategory Name ← (QUOTE Browser% Events)
				     MenuItems ← (QUOTE (Recompute% Browser Relayout% Browser))
				     MenuItemsFn ← NIL DefaultMenuItems ← (QUOTE (Recompute% Browser))
				     DefaultMenuItemsFn ← NIL MenuChoicesFn ← NIL))

(RPAQ NCHist.CardTypeEvents (create EventCategory Name ← (QUOTE Card% Type% Events)
				      MenuItems ← (QUOTE (Add% Card% Type))
				      MenuItemsFn ← NIL DefaultMenuItems ← NIL DefaultMenuItemsFn ← 
				      NIL MenuChoicesFn ← NIL))

(RPAQ NCHist.EventCategories (LIST NCHist.CardEvents NCHist.CreateLinkEvents 
				     NCHist.DeleteLinkEvents NCHist.BrowserEvents 
				     NCHist.CardTypeEvents))
(* * General automated history card functions)

(DEFINEQ

(NCHist.CreateHistoryDate
  (LAMBDA (Card)                                             (* pmi: "14-Dec-87 12:06")

          (* * Creates date for history card.)


    (LET ((SystemDate (DATE (DATEFORMAT NO.TIME NUMBER.OF.MONTH))))
         (CONCAT (NCHist.ShaveLeadingSpace (SUBSTRING SystemDate 4 5))
		   "/"
		   (NCHist.ShaveLeadingSpace (SUBSTRING SystemDate 1 2))
		   "/"
		   (NCHist.ShaveLeadingSpace (SUBSTRING SystemDate 7 8))))))

(NCHist.ComputeHistory
  [LAMBDA (Window)                                           (* edited: "15-Dec-87 11:34")

          (* * Computes stuff for History card.)


    (DECLARE (GLOBALVARS NCHist.HistoryEventHashArray NCHist.HistoryLinkType))
    (PROG ((HistoryCard (NCP.CoerceToCard Window))
	     NoteFile NCLogInfo ActiveCards)
	    (SETQ NoteFile (NCP.CardNoteFile HistoryCard))
	    (SETQ NCLogInfo (NCP.CardUserDataProp HistoryCard (QUOTE NCLogInfo)))
	    (SETQ ActiveCards (NC.MapCards NoteFile (FUNCTION [LAMBDA (Card)
						 Card])
					     (FUNCTION NC.ActiveCardP)))

          (* * Warn the user about changes to unsaved cards not being logged until a checkpoint is done.)


	    (if [for ActiveCard in ActiveCards thereis (AND (NC.CardDirtyP ActiveCard)
								      (NEQ ActiveCard
									     (fetch (NoteFile
											
										   LinkLabelsCard)
										of NoteFile))
								      (NEQ ActiveCard
									     (fetch (NoteFile
											RegistryCard)
										of NoteFile))
								      (NEQ ActiveCard
									     (NCP.LookupCardByName
									       (QUOTE 
										   OpenEventsCard)
									       NoteFile]
		then (SELECTQ (NC.AskUserWithMenu (QUOTE (Yes No Cancel))
							(CONCAT 
			    "Warning - information about cards not yet saved will not be logged."
								  (CHARACTER 13)
								  
							   "Checkpoint before computing history?")
							Window NIL T)
				  (Yes (NCP.CheckpointNoteFiles NoteFile))
				  (No)
				  (Cancel (RETURN NIL))
				  (RETURN NIL)))
	    (RETURN (RESETLST (RESETSAVE (BQUOTE (NCLOG.SuspendLogging , NoteFile , 
										 NCLogInfo))
					       (BQUOTE (NCLOG.StartLogging , NoteFile , NCLogInfo)
							 ))
				  (LET (LoggingStream SectionEndPtr SectionPtrs HistoryEventTypes)
				       (SETQ LoggingStream (fetch (NCLogInfo LoggingStream)
								of NCLogInfo))
				       (SETQ SectionEndPtr (GETEOFPTR LoggingStream))
				       (SETQ SectionPtrs (NCP.CardUserDataProp HistoryCard
										   (QUOTE 
										      SectionPtrs)))

          (* * Compute history for current section if it has not already been computed.)


				       (if (NOT (NCP.ValidLinkTypeP NCHist.HistoryLinkType 
									  NoteFile))
					   then (NCP.CreateLinkType NCHist.HistoryLinkType 
									NoteFile))
				       (if (NOT (FMEMB SectionEndPtr SectionPtrs))
					   then (if SectionPtrs
						      then (SETQ SectionStartPtr
							       (CAR (LAST SectionPtrs)))
						    else (SETQ SectionStartPtr 0))
						  (SETQ SectionPtrs (NCONC1 SectionPtrs 
										SectionEndPtr))
						  (NCP.CardUserDataProp HistoryCard (QUOTE 
										      SectionPtrs)
									  SectionPtrs)
						  (SETQ HistoryEventTypes) 

          (* * Gather up all of the events to be logged for this History card. They are stored on the History card, as 
	  separate lists for each event category.)


						  [for HistoryEventList in (NCP.CardUserDataProp
										 HistoryCard
										 (QUOTE 
										HistoryEventSpecs))
						     do (for HistoryEventType in 
										 HistoryEventList
							     do (SETQ HistoryEventTypes
								    (APPEND (MKLIST (GETHASH
											  
										 HistoryEventType 
								     NCHist.HistoryEventHashArray))
									      HistoryEventTypes]
						  (SETFILEPTR LoggingStream SectionStartPtr)
						  (while (NOT (EOFP LoggingStream))
						     first (SKIPSEPRS LoggingStream)
						     finally (NCP.CardAddText
								 HistoryCard
								 (CONCAT (CHARACTER 13)
									   "--- "
									   (DATE (DATEFORMAT
										     NO.DATE 
										     NO.SECONDS))
									   " ---"
									   (CHARACTER 13)
									   (CHARACTER 13))
								 (QUOTE END))
						     do (NCHist.GetLogEventFromStream 
										    LoggingStream 
										HistoryEventTypes 
										      HistoryCard])

(NCHist.GetLogEventFromStream
  (LAMBDA (Stream HistoryEventTypes HistoryCard)             (* pmi: " 2-Dec-87 11:39")
    (LET (LogEvent EventType)
         (SKIPSEPRS Stream)
         (if (NOT (EOFP Stream))
	     then (SETQ LogEvent (READ Stream))
		    (SETQ EventType (CAR LogEvent))
		    (if (FMEMB EventType HistoryEventTypes)
			then (APPLY (GETHASH EventType NCHist.LogEventFnHashArray)
					(CONS HistoryCard (CDR LogEvent)))))
     LogEvent)))

(NCHist.ProcessLogEvent
  (LAMBDA (HistoryCard EventType EventTypeArgs)              (* pmi: "23-Nov-87 12:15")
    (DECLARE (GLOBALVARS NCLOG.UIDHashArray NCHist.LogEventFnHashArray))
    (APPLY (GETHASH EventType NCHist.LogEventFnHashArray)
	     (CONS HistoryCard EventTypeArgs))))

(NCHist.ChangeHistoryEventSpecs
  (LAMBDA (Window)                                           (* pmi: " 2-Dec-87 10:51")

          (* * Change the values of the various History event specs)


    (LET ((Card (NCP.CoerceToCard Window)))
         (NC.ProtectedCardOperation Card "History Event Specs" NIL (PROG (HistoryEventSpecs)
								           (SETQ HistoryEventSpecs
									     (
								      NCHist.AskHistoryEventSpecs
									       Window Card))

          (* * NC.SetPropListDirtyFlg Card T)


								           (NCP.CardUserDataProp
									     Card
									     (QUOTE 
										HistoryEventSpecs)
									     HistoryEventSpecs)
								           (NC.ClearMsg Window T))))
    ))

(NCHist.AskHistoryEventSpecs
  [LAMBDA (MainWindow HistoryCard)                           (* edited: "15-Dec-87 09:17")

          (* * Puts up a stylesheet asking user about events, link types, etc. over which to compute the next history.
	  The stylesheet returns a list of n things: %.)


    (DECLARE (GLOBALVARS NCHist.HistoryEventsSpecsStylesheet NCHist.EventCategories NC.MenuFont))
    (PROG (NoteFile OldEvents Position Choices)
	    (SETQ NoteFile (NCP.CardNoteFile HistoryCard))
	    (SETQ OldEvents (NCP.CardUserDataProp HistoryCard (QUOTE DefaultHistoryEventSpecs)))
	    (if NCHist.HistoryEventsSpecsStylesheet
	      else (NCHist.InitializeHistoryEventsSpecsStylesheet))
	    [SETQ Position (AND (WINDOWP MainWindow)
				    (create POSITION
					      XCOORD ←(fetch (REGION LEFT)
							 of (WINDOWPROP MainWindow (QUOTE
									      REGION)))
					      YCOORD ←(fetch (REGION TOP) of (WINDOWREGION
										   MainWindow]
                                                             (* The stylesheet is in a global var.
							     We only need to provide its position, items, and 
							     selections.)
	    (STYLE.PROP NCHist.HistoryEventsSpecsStylesheet (QUOTE POSITION)
			  Position)
	    (STYLE.PROP NCHist.HistoryEventsSpecsStylesheet (QUOTE ITEMS)
			  (for EventCategory in NCHist.EventCategories
			     collect (create MENU
						 ITEMS ←(if (fetch (EventCategory MenuItems)
								 of EventCategory)
							  else (APPLY* (fetch (EventCategory
										      MenuItemsFn)
									      of EventCategory)
									   NoteFile))
						 MENUFONT ← NC.MenuFont)))
	    [STYLE.PROP NCHist.HistoryEventsSpecsStylesheet (QUOTE SELECTIONS)
			  (OR OldEvents (for EventCategory in NCHist.EventCategories
					     bind DefaultMenuItemsFn
					     collect (if (fetch (EventCategory DefaultMenuItems)
								of EventCategory)
							 elseif (SETQ DefaultMenuItemsFn
								    (fetch (EventCategory 
									       DefaultMenuItemsFn)
								       of EventCategory))
							   then (APPLY* DefaultMenuItemsFn 
									    NoteFile]
	    (if (SETQ Choices (STYLESHEET NCHist.HistoryEventsSpecsStylesheet))
		then (NCP.CardUserDataProp HistoryCard (QUOTE DefaultHistoryEventSpecs)
					       Choices)
		       (RETURN (for CategoryChoices in Choices as EventCategory in 
									   NCHist.EventCategories
				    bind MenuChoicesFn collect (if (SETQ MenuChoicesFn
									   (fetch (EventCategory
										      MenuChoicesFn)
									      of EventCategory))
								       then (APPLY* MenuChoicesFn 
										  CategoryChoices 
										      HistoryCard 
											NoteFile)
								     else CategoryChoices)))
	      else (RETURN OldEvents])

(NCHist.InitializeHistoryEventsSpecsStylesheet
  (LAMBDA NIL                                                (* pmi: " 2-Dec-87 11:20")

          (* * pmi 10/30/87: Build a stylesheet for the History Event Specs, using the events stored by category in the ASSOC
	  list NCLOG.ListOfEventTypes.)


    (DECLARE (GLOBALVARS NCHist.HistoryEventsSpecsStylesheet NCHist.EventCategories NC.MenuFont))
    (LET (NumCategories)
         (SETQ NumCategories (LENGTH NCHist.EventCategories))
         (SETQ NCHist.HistoryEventsSpecsStylesheet (CREATE.STYLE (QUOTE ITEMS)
								     (from 1 to NumCategories
									collect (create MENU
											    ITEMS ← T)
									     )
								     (QUOTE SELECTIONS)
								     (from 1 to NumCategories
									collect T)
								     (QUOTE ITEM.TITLES)
								     (for EventCategory
									in NCHist.EventCategories
									collect
									 (fetch (EventCategory
										    Name)
									    of EventCategory))
								     (QUOTE ITEM.TITLE.FONT)
								     (FONTCOPY NC.MenuFont
										 (QUOTE WEIGHT)
										 (QUOTE BOLD))
								     (QUOTE NEED.NOT.FILL.IN)
								     (from 1 to NumCategories
									collect (QUOTE MULTI))
								     (QUOTE TITLE)
								     "History Event Specs?")))))

(NCHist.InitializeHistoryEventHashArray
  (LAMBDA NIL
    (DECLARE (GLOBALVARS NCHist.HistoryEventHashArray NCLOG.HashArraySize))
                                                             (* pmi: "24-Nov-87 13:30")
    (if (HARRAYP NCHist.HistoryEventHashArray)
      else (SETQ NCHist.HistoryEventHashArray (HASHARRAY NCLOG.HashArraySize)))
    (PUTHASH (QUOTE Create% Card)
	       (QUOTE GetNewCard)
	       NCHist.HistoryEventHashArray)
    (PUTHASH (QUOTE Bring% Up% Card)
	       (QUOTE EditCard.End)
	       NCHist.HistoryEventHashArray)
    (PUTHASH (QUOTE Close% Card)
	       (QUOTE QuitCard.End)
	       NCHist.HistoryEventHashArray)
    (PUTHASH (QUOTE Change% Card% Substance)
	       (QUOTE PutMainCardData)
	       NCHist.HistoryEventHashArray)
    (PUTHASH (QUOTE Change% Card% Prop% List)
	       (QUOTE PutPropList)
	       NCHist.HistoryEventHashArray)
    (PUTHASH (QUOTE Change% Card% Title)
	       (QUOTE (AssignTitle.Begin PutTitle))
	       NCHist.HistoryEventHashArray)
    (PUTHASH (QUOTE Delete% Card)
	       (QUOTE DelCard)
	       NCHist.HistoryEventHashArray)
    (PUTHASH (QUOTE Create% Link)
	       (QUOTE MakeLink)
	       NCHist.HistoryEventHashArray)
    (PUTHASH (QUOTE Delete% Link)
	       (QUOTE DelLink)
	       NCHist.HistoryEventHashArray)
    (PUTHASH (QUOTE Recompute% Browser)
	       (QUOTE RecomputeBrowser.End)
	       NCHist.HistoryEventHashArray)
    (PUTHASH (QUOTE Relayout% Browser)
	       (QUOTE RelayoutBrowser.End)
	       NCHist.HistoryEventHashArray)
    (PUTHASH (QUOTE Add% Card% Type)
	       (QUOTE AddCardType)
	       NCHist.HistoryEventHashArray)
    NCHist.HistoryEventHashArray))

(NCHist.InitializeLogEventFnHashArray
  (LAMBDA NIL                                                (* pmi: "24-Nov-87 13:31")
    (DECLARE (GLOBALVARS NCHist.LogEventFnHashArray NCLOG.HashArraySize))
    (if (HARRAYP NCHist.LogEventFnHashArray)
      else (SETQ NCHist.LogEventFnHashArray (HASHARRAY NCLOG.HashArraySize)))
    (PUTHASH (QUOTE GetNewCard)
	       (QUOTE NCHist.GetNewCardDisplayFn)
	       NCHist.LogEventFnHashArray)
    (PUTHASH (QUOTE EditCard.End)
	       (QUOTE NCHist.EditCard.EndDisplayFn)
	       NCHist.LogEventFnHashArray)
    (PUTHASH (QUOTE QuitCard.End)
	       (QUOTE NCHist.QuitCard.EndDisplayFn)
	       NCHist.LogEventFnHashArray)
    (PUTHASH (QUOTE PutMainCardData)
	       (QUOTE NCHist.PutMainCardDataDisplayFn)
	       NCHist.LogEventFnHashArray)
    (PUTHASH (QUOTE PutPropList)
	       (QUOTE NCHist.PutPropListDisplayFn)
	       NCHist.LogEventFnHashArray)
    (PUTHASH (QUOTE AssignTitle.Begin)
	       (QUOTE NCHist.AssignTitle.BeginDisplayFn)
	       NCHist.LogEventFnHashArray)
    (PUTHASH (QUOTE PutTitle)
	       (QUOTE NCHist.PutTitleDisplayFn)
	       NCHist.LogEventFnHashArray)
    (PUTHASH (QUOTE DelCard)
	       (QUOTE NCHist.DelCardDisplayFn)
	       NCHist.LogEventFnHashArray)
    (PUTHASH (QUOTE MakeLink)
	       (QUOTE NCHist.MakeLinkDisplayFn)
	       NCHist.LogEventFnHashArray)
    (PUTHASH (QUOTE DelLink)
	       (QUOTE NCHist.DelLinkDisplayFn)
	       NCHist.LogEventFnHashArray)
    (PUTHASH (QUOTE RecomputeBrowser.End)
	       (QUOTE NCHist.RecomputeBrowser.EndDisplayFn)
	       NCHist.LogEventFnHashArray)
    (PUTHASH (QUOTE RelayoutBrowser.End)
	       (QUOTE NCHist.RelayoutBrowser.EndDisplayFn)
	       NCHist.LogEventFnHashArray)
    (PUTHASH (QUOTE AddCardType)
	       (QUOTE NCHist.AddCardTypeDisplayFn)
	       NCHist.LogEventFnHashArray)
    NCHist.LogEventFnHashArray))

(NCHist.ConvertPointersToLinks
  (LAMBDA (Window)                                           (* pmi: "25-Nov-87 12:45")
    (LET (PointerIcons)
         (SETQ PointerIcons (TEDIT.LIST.OF.OBJECTS (TEXTOBJ Window)
						       (FUNCTION NC.PointerIconImageObjP)))
         (for PointerIcon in PointerIcons do (NC.ConvertPointerIconToLinkIcon Window
										      (CAR 
										      PointerIcon)))
     Window)))

(NCHist.TurnLoggingOn
  (LAMBDA (Card)                                             (* pmi: "22-Oct-87 12:10")

          (* * Start up logging for this notefile.)


    (NCLOG.StartLogging (NCP.CardNoteFile Card))))

(NCHist.TurnLoggingOff
  (LAMBDA (Card)                                             (* pmi: "22-Oct-87 12:11")

          (* * Suspend logging for this notefile.)


    (NCLOG.SuspendLogging (NCP.CardNoteFile Card))))
)
(* * Fns for the various event category functions)

(DEFINEQ

(NCHist.CreateLinkEventsMenuItemsFn
  (LAMBDA (NoteFile)                                         (* pmi: " 2-Dec-87 11:35")
    (REVERSE (NCP.LinkTypes NoteFile))))

(NCHist.CreateLinkEventsDefaultMenuChoicesFn
  (LAMBDA (NoteFile)                                         (* pmi: " 2-Dec-87 10:23")
    (REMOVE (QUOTE History)
	      (APPEND (NCP.UserLinkTypes NoteFile)
			(QUOTE (FiledCard SubBox))))))

(NCHist.CreateLinkEventsMenuChoicesFn
  (LAMBDA (Choices HistoryCard NoteFile)                     (* pmi: " 2-Dec-87 11:22")
    (NCP.CardUserDataProp HistoryCard (QUOTE CreateLinkTypesToLog)
			    Choices)
    (QUOTE (Create% Link))))

(NCHist.DeleteLinkEventsMenuItemsFn
  (LAMBDA (NoteFile)                                         (* pmi: " 2-Dec-87 11:35")
    (REVERSE (NCP.LinkTypes NoteFile))))

(NCHist.DeleteLinkEventsDefaultMenuChoicesFn
  (LAMBDA (NoteFile)                                         (* pmi: " 2-Dec-87 10:23")
    (REMOVE (QUOTE History)
	      (APPEND (NCP.UserLinkTypes NoteFile)
			(QUOTE (FiledCard SubBox))))))

(NCHist.DeleteLinkEventsMenuChoicesFn
  (LAMBDA (Choices HistoryCard NoteFile)                     (* pmi: " 2-Dec-87 11:22")
    (NCP.CardUserDataProp HistoryCard (QUOTE DeleteLinkTypesToLog)
			    Choices)
    (QUOTE (Delete% Link))))
)
(* * Fns called to display the events in the History Card)

(DEFINEQ

(NCHist.EditCard.BeginDisplayFn
  (LAMBDA (HistoryCard EventTime NoteFile Card)))

(NCHist.EditCard.EndDisplayFn
  (LAMBDA (HistoryCard EventTime NoteFileNum CardNum)        (* pmi: "23-Nov-87 15:13")
    (DECLARE (GLOBALVARS NCHist.HistoryLinkType))
    (LET* ((NoteFile (NC.NoteFileFromUID (NCLOG.UIDFromNum NoteFileNum)))
	   (Card (NC.CardFromUID (NCLOG.UIDFromNum CardNum)
				   NoteFile)))
          (if (NEQ Card HistoryCard)
	      then (NCP.CardAddText HistoryCard "Brought up " (QUOTE END))
		     (NC.InsertPointerInText HistoryCard Card NCHist.HistoryLinkType
					       (NCP.CoerceToLinkDisplayMode (QUOTE (FLOAT
											 FLOAT FLOAT))
									      ))
		     (NCP.CardAddText HistoryCard (CHARACTER 13)
					(QUOTE END))))))

(NCHist.QuitCard.BeginDisplayFn
  (LAMBDA (HistoryCard EventTime NoteFile Card Don'tDeactivateFlg)))

(NCHist.QuitCard.EndDisplayFn
  (LAMBDA (HistoryCard EventTime NoteFileNum CardNum Don'tDeactivateFlg)
                                                             (* pmi: "23-Nov-87 15:18")
    (DECLARE (GLOBALVARS NCHist.HistoryLinkType))
    (LET* ((NoteFile (NC.NoteFileFromUID (NCLOG.UIDFromNum NoteFileNum)))
	   (Card (NC.CardFromUID (NCLOG.UIDFromNum CardNum)
				   NoteFile)))
          (if (NEQ Card HistoryCard)
	      then (NCP.CardAddText HistoryCard "Closed " (QUOTE END))
		     (NC.InsertPointerInText HistoryCard Card NCHist.HistoryLinkType
					       (NCP.CoerceToLinkDisplayMode (QUOTE (FLOAT
											 FLOAT FLOAT))
									      ))
		     (NCP.CardAddText HistoryCard (CHARACTER 13)
					(QUOTE END))))))

(NCHist.MakeCard.BeginDisplayFn
  (LAMBDA (HistoryCard EventTime NoteFileNum CardType Title NewCardNum)
                                                             (* pmi: "24-Nov-87 17:47")
    NIL))

(NCHist.MakeCard.EndDisplayFn
  (LAMBDA (HistoryCard EventTime NoteFileNum CardType Title CardNum)
                                                             (* pmi: "23-Nov-87 18:59")
    (DECLARE (GLOBALVARS NCHist.HistoryLinkType))
    (LET* ((NoteFile (NC.NoteFileFromUID (NCLOG.UIDFromNum NoteFileNum)))
	   (Card (NC.CardFromUID (NCLOG.UIDFromNum CardNum)
				   NoteFile)))
          (if (NEQ Card HistoryCard)
	      then (NCP.CardAddText HistoryCard "Created " (QUOTE END))
		     (if CardType
			 then (NCP.CardAddText HistoryCard (MKSTRING CardType)
						   (QUOTE END)))
		     (NCP.CardAddText HistoryCard " card " (QUOTE END))
		     (NC.InsertPointerInText HistoryCard Card NCHist.HistoryLinkType
					       (NCP.CoerceToLinkDisplayMode (QUOTE (FLOAT
											 FLOAT FLOAT))
									      ))
		     (if Title
			 then (NCP.CardAddText HistoryCard (CONCAT " with title " Title)
						   (QUOTE END)))
		     (NCP.CardAddText HistoryCard (CHARACTER 13)
					(QUOTE END))))))

(NCHist.GetNewCardDisplayFn
  [LAMBDA (HistoryCard EventTime NoteFileNum CardNum CardType)
                                                             (* edited: "14-Dec-87 20:46")
    (DECLARE (GLOBALVARS NCHist.HistoryLinkType))
    (LET* ((NoteFile (NC.NoteFileFromUID (NCLOG.UIDFromNum NoteFileNum)))
	   (Card (NC.CardFromUID (NCLOG.UIDFromNum CardNum)
				   NoteFile)))
          (if (AND Card (NEQ Card HistoryCard))
	      then (NCP.CardAddText HistoryCard "Created " (QUOTE END))
		     (if CardType
			 then (NCP.CardAddText HistoryCard (MKSTRING CardType)
						   (QUOTE END)))
		     (NCP.CardAddText HistoryCard " card " (QUOTE END))
		     [NC.InsertPointerInText HistoryCard Card NCHist.HistoryLinkType
					       (NCP.CoerceToLinkDisplayMode (QUOTE (FLOAT
											 FLOAT FLOAT]
		     (NCP.CardAddText HistoryCard (CHARACTER 13)
					(QUOTE END])

(NCHist.DelCardDisplayFn
  (LAMBDA (HistoryCard EventTime NoteFile Card Title)        (* pmi: "23-Nov-87 17:40")
    (if (NEQ Card HistoryCard)
	then (NCP.CardAddText HistoryCard (CONCAT "Deleted card '" Title "'" (CHARACTER
							  13))
				  (QUOTE END)))))

(NCHist.CacheCardDisplayFn
  (LAMBDA (HistoryCard EventTime NoteFile Card)              (* pmi: "20-Nov-87 12:14")
    (NCP.CardAddText HistoryCard (CONCAT "Cached card " Card (CHARACTER 13)))))

(NCHist.UncacheCardDisplayFn
  (LAMBDA (HistoryCard EventTime NoteFile Card)              (* pmi: "20-Nov-87 12:14")
    (NCP.CardAddText HistoryCard (CONCAT "Uncached card " Card (CHARACTER 13)))))

(NCHist.SaveCard.BeginDisplayFn
  (LAMBDA (HistoryCard EventTime NoteFile Card)))

(NCHist.SaveCard.EndDisplayFn
  (LAMBDA (HistoryCard EventTime NoteFile Card)              (* pmi: "20-Nov-87 12:14")
    (NCP.CardAddText HistoryCard (CONCAT "Changed card " Card (CHARACTER 13)))))

(NCHist.PutLinksDisplayFn
  (LAMBDA (HistoryCard EventTime NoteFile Card)              (* pmi: "20-Nov-87 12:16")
    (NCP.CardAddText HistoryCard (CONCAT "Put links for card " Card (CHARACTER 13)))))

(NCHist.PutMainCardDataDisplayFn
  [LAMBDA (HistoryCard EventTime NoteFileNum CardNum)        (* edited: "15-Dec-87 09:34")
    (DECLARE (GLOBALVARS NCHist.HistoryLinkType))
    (LET* ((NoteFile (NC.NoteFileFromUID (NCLOG.UIDFromNum NoteFileNum)))
	   (Card (NC.CardFromUID (NCLOG.UIDFromNum CardNum)
				   NoteFile)))
          (if (AND Card (NEQ Card HistoryCard)
		       (NEQ Card (fetch (NoteFile LinkLabelsCard) of NoteFile))
		       (NEQ Card (fetch (NoteFile RegistryCard) of NoteFile))
		       (NEQ Card (NCP.LookupCardByName (QUOTE OpenEventsCard)
							   NoteFile)))
	      then (NCP.CardAddText HistoryCard "Changed contents of " (QUOTE END))
		     [NC.InsertPointerInText HistoryCard Card NCHist.HistoryLinkType
					       (NCP.CoerceToLinkDisplayMode (QUOTE (FLOAT
											 FLOAT FLOAT]
		     (NCP.CardAddText HistoryCard (CHARACTER 13)
					(QUOTE END])

(NCHist.PutPropListDisplayFn
  [LAMBDA (HistoryCard EventTime NoteFileNum CardNum)        (* edited: "15-Dec-87 09:49")
    (DECLARE (GLOBALVARS NCHist.HistoryLinkType))
    (LET* ((NoteFile (NC.NoteFileFromUID (NCLOG.UIDFromNum NoteFileNum)))
	   (Card (NC.CardFromUID (NCLOG.UIDFromNum CardNum)
				   NoteFile)))
          (if (AND Card (NEQ Card HistoryCard)
		       (NEQ Card (fetch (NoteFile LinkLabelsCard) of NoteFile))
		       (NEQ Card (fetch (NoteFile RegistryCard) of NoteFile))
		       (NEQ Card (NCP.LookupCardByName (QUOTE OpenEventsCard)
							   NoteFile)))
	      then (NCP.CardAddText HistoryCard "Changed property list of " (QUOTE END))
		     [NC.InsertPointerInText HistoryCard Card NCHist.HistoryLinkType
					       (NCP.CoerceToLinkDisplayMode (QUOTE (FLOAT
											 FLOAT FLOAT]
		     (NCP.CardAddText HistoryCard (CHARACTER 13)
					(QUOTE END])

(NCHist.PutTitleDisplayFn
  [LAMBDA (HistoryCard EventTime NoteFileNum CardNum)        (* edited: "15-Dec-87 09:53")
    (DECLARE (GLOBALVARS NCHist.HistoryLinkType))
    (LET* ((NoteFile (NC.NoteFileFromUID (NCLOG.UIDFromNum NoteFileNum)))
	   (Card (NC.CardFromUID (NCLOG.UIDFromNum CardNum)
				   NoteFile))
	   OldTitle)
          (if (AND Card (NEQ Card HistoryCard)
		       (NEQ Card (fetch (NoteFile LinkLabelsCard) of NoteFile))
		       (NEQ Card (fetch (NoteFile RegistryCard) of NoteFile))
		       (NEQ Card (NCP.LookupCardByName (QUOTE OpenEventsCard)
							   NoteFile)))
	      then (NCP.CardAddText HistoryCard "Changed title of " (QUOTE END))
		     [NC.InsertPointerInText HistoryCard Card NCHist.HistoryLinkType
					       (NCP.CoerceToLinkDisplayMode (QUOTE (FLOAT
											 FLOAT FLOAT]
		     (if (SETQ OldTitle (NCP.CardUserDataProp HistoryCard (QUOTE Card)))
			 then (NCP.CardAddText HistoryCard (CONCAT " from '" OldTitle "' to '"
									 (NCP.CardTitle Card)
									 "'")
						   (QUOTE END))
				(NCP.CardUserDataProp HistoryCard (QUOTE Card)
							NIL))
		     (NCP.CardAddText HistoryCard (CHARACTER 13)
					(QUOTE END])

(NCHist.AssignTitle.BeginDisplayFn
  (LAMBDA (HistoryCard EventTime NoteFile Card OldTitle)     (* pmi: "20-Nov-87 16:53")
    (if (NCP.CardUserDataProp HistoryCard (QUOTE Card))
      else (NCP.CardUserDataProp HistoryCard (QUOTE Card)
				     OldTitle))))

(NCHist.AssignTitle.EndDisplayFn
  (LAMBDA (HistoryCard EventTime NoteFile Card NewTitle)     (* pmi: "20-Nov-87 12:19")
    (NCP.CardAddText HistoryCard (CONCAT " to " NewTitle (CHARACTER 13)))))

(NCHist.MakeLinkDisplayFn
  (LAMBDA (HistoryCard EventTime NoteFileNum LinkNum SourceCardNum DestinationCardNum Label 
		       AnchorMode DisplayMode)               (* pmi: " 2-Dec-87 10:56")
    (DECLARE (GLOBALVARS NCHist.HistoryLinkType))
    (LET* ((NoteFile (NC.NoteFileFromUID (NCLOG.UIDFromNum NoteFileNum)))
	   (SourceCard (NC.CardFromUID (NCLOG.UIDFromNum SourceCardNum)
					 NoteFile))
	   (DestinationCard (NC.CardFromUID (NCLOG.UIDFromNum DestinationCardNum)
					      NoteFile)))
          (if (AND (NEQ SourceCard HistoryCard)
		       (MEMBER Label (NCP.CardUserDataProp HistoryCard (QUOTE 
									     CreateLinkTypesToLog))))
	      then (NCP.CardAddText HistoryCard (CONCAT "Created " Label " link from ")
					(QUOTE END))
		     (NC.InsertPointerInText HistoryCard SourceCard NCHist.HistoryLinkType
					       (NCP.CoerceToLinkDisplayMode (QUOTE (FLOAT
											 FLOAT FLOAT))
									      ))
		     (NCP.CardAddText HistoryCard " to " (QUOTE END))
		     (NC.InsertPointerInText HistoryCard DestinationCard NCHist.HistoryLinkType
					       (NCP.CoerceToLinkDisplayMode (QUOTE (FLOAT
											 FLOAT FLOAT))
									      ))
		     (NCP.CardAddText HistoryCard (CHARACTER 13)
					(QUOTE END))))))

(NCHist.DelLinkDisplayFn
  (LAMBDA (HistoryCard EventTime NoteFileNum LinkNum SourceCardNum DestinationCardNum Label 
		       AnchorMode DisplayMode)               (* pmi: " 2-Dec-87 10:56")
    (DECLARE (GLOBALVARS NCHist.HistoryLinkType))
    (LET* ((NoteFile (NC.NoteFileFromUID (NCLOG.UIDFromNum NoteFileNum)))
	   (SourceCard (NC.CardFromUID (NCLOG.UIDFromNum SourceCardNum)
					 NoteFile))
	   (DestinationCard (NC.CardFromUID (NCLOG.UIDFromNum DestinationCardNum)
					      NoteFile)))
          (if (AND (NEQ SourceCard HistoryCard)
		       (MEMBER Label (NCP.CardUserDataProp HistoryCard (QUOTE 
									     DeleteLinkTypesToLog))))
	      then (NCP.CardAddText HistoryCard (CONCAT "Deleted " Label " link from ")
					(QUOTE END))
		     (NC.InsertPointerInText HistoryCard SourceCard NCHist.HistoryLinkType
					       (NCP.CoerceToLinkDisplayMode (QUOTE (FLOAT
											 FLOAT FLOAT))
									      ))
		     (NCP.CardAddText HistoryCard " to " (QUOTE END))
		     (NC.InsertPointerInText HistoryCard DestinationCard NCHist.HistoryLinkType
					       (NCP.CoerceToLinkDisplayMode (QUOTE (FLOAT
											 FLOAT FLOAT))
									      ))
		     (NCP.CardAddText HistoryCard (CHARACTER 13)
					(QUOTE END))))))

(NCHist.RecomputeBrowser.BeginDisplayFn
  (LAMBDA (HistoryCard EventTime NoteFile Card)))

(NCHist.RecomputeBrowser.EndDisplayFn
  (LAMBDA (HistoryCard EventTime NoteFileNum CardNum)        (* pmi: "24-Nov-87 09:39")
    (DECLARE (GLOBALVARS NCHist.HistoryLinkType))
    (LET* ((NoteFile (NC.NoteFileFromUID (NCLOG.UIDFromNum NoteFileNum)))
	   (Card (NC.CardFromUID (NCLOG.UIDFromNum CardNum)
				   NoteFile)))
          (if (NEQ Card HistoryCard)
	      then (NCP.CardAddText HistoryCard "Recomputed browser " (QUOTE END))
		     (NC.InsertPointerInText HistoryCard Card NCHist.HistoryLinkType
					       (NCP.CoerceToLinkDisplayMode (QUOTE (FLOAT
											 FLOAT FLOAT))
									      ))
		     (NCP.CardAddText HistoryCard (CHARACTER 13)
					(QUOTE END))))))

(NCHist.RelayoutBrowser.BeginDisplayFn
  (LAMBDA (HistoryCard EventTime NoteFile Card)))

(NCHist.RelayoutBrowser.EndDisplayFn
  (LAMBDA (HistoryCard EventTime NoteFileNum CardNum)        (* pmi: "24-Nov-87 17:44")
    (DECLARE (GLOBALVARS NCHist.HistoryLinkType))
    (LET* ((NoteFile (NC.NoteFileFromUID (NCLOG.UIDFromNum NoteFileNum)))
	   (Card (NC.CardFromUID (NCLOG.UIDFromNum CardNum)
				   NoteFile)))
          (if (NEQ Card HistoryCard)
	      then (NCP.CardAddText HistoryCard "Re-laid out " (QUOTE END))
		     (NC.InsertPointerInText HistoryCard Card NCHist.HistoryLinkType
					       (NCP.CoerceToLinkDisplayMode (QUOTE (FLOAT
											 FLOAT FLOAT))
									      ))
		     (NCP.CardAddText HistoryCard (CHARACTER 13)
					(QUOTE END))))))

(NCHist.AddCardTypeDisplayFn
  (LAMBDA (HistoryCard EventTime TypeName)                   (* pmi: "20-Nov-87 18:20")
    (NCP.CardAddText HistoryCard (CONCAT "Added card type " TypeName (CHARACTER 13))
		       (QUOTE END))))

(NCHist.StartLoggingDisplayFn
  (LAMBDA (HistoryCard EventTime NoteFile FullNoteFileName)))
)
(NCHist.InitializeHistoryEventsSpecsStylesheet)
(NCHist.InitializeHistoryEventHashArray)
(NCHist.InitializeLogEventFnHashArray)
(* * Changed in NCCOLLABORATION)

(DEFINEQ

(NCCollab.OpenNoteFileFn
  (LAMBDA (NoteFile)                                         (* pmi: "21-Oct-87 12:43")

          (* * This gets called at notefile-open time.)



          (* * pmi 10/21/87: Now prompts for new collaborator name before creating the collaborator card, rather than 
	  creating a collaborator card with "??" as the title.)


    (LET ((UserName (USERNAME))
	  Menu CollaboratorCard MenuItemRegion)
         (NCP.AddNoteFileIconMiddleButtonItems NoteFile NCCollab.NoteFileIconMiddleMenuItems)
         (SETQ Menu (NCCollab.MakeCollaboratorsMenu NoteFile (QUOTE (("-- New Name(s) --"
									      (QUOTE NEWNAMES)
									      
						    "Create a new collaborator information card.")))))
         (NCP.PrintMsg NIL T "Please select Collaborator name(s)")
                                                             (* Make Menu be positioned next to UserName if 
							     present, otherwise at "NewNames" entry.)
         (SETQ MenuItemRegion (MENUITEMREGION (for Item in (fetch (MENU ITEMS)
								      of Menu)
						     when (STREQUAL (U-CASE (CAR Item))
									(U-CASE UserName))
						     do (RETURN Item) finally (RETURN Item))
						  Menu))
         (replace (MENU MENUOFFSET) of Menu with (CONS (fetch (REGION LEFT) of 
										   MenuItemRegion)
								 (fetch (REGION BOTTOM)
								    of MenuItemRegion)))
         (if (EQ (SETQ CollaboratorCard (MENU Menu))
		     (QUOTE NEWNAMES))
	     then                                          (* Create a new card with unknown title if UserName is
							     on menu, else use UserName.)
		    (SETQ CollaboratorCard (NCP.CoerceToCard
			(NCP.CreateCard (QUOTE Collaborator)
					  NoteFile
					  (if (for Item in (fetch (MENU ITEMS)
								    of Menu)
						   thereis (STREQUAL (CAR Item)
									 UserName))
					      then (NCP.AskUser 
							"Enter new name(s) for collaborator(s): "
								    NIL NIL T (
								      NC.CoerceToInterestedWindow
								      NoteFile))
					    else UserName))))
		    (NCCollab.HangOnCardUntilDone CollaboratorCard "DONE" "Fill in parameters" 
"Selecting DONE indicates completion of updating this card.  Will allow OpenNoteFile to continue."))
         (if (NCP.ValidCardP CollaboratorCard)
	     then (NCCollab.ChangeCurrentCollaborator NoteFile CollaboratorCard)))))
)
(* * Add this expression to the end of the file coms for NCCOLLABORATION)

(NCP.AddSessionIconMenuItem (QUOTE NoteFile)
			    (QUOTE (% Collaboratize%  NCCollab.CollaboratizeNoteFile 
						      "Collaboratizes a notefile.")))
(NCP.AddNoteFileIconMenuItem (QUOTE (Collaboratize NCCollab.CollaboratizeNoteFile 
						   "Collaboratizes a notefile."))
			     (QUOTE Open))
(* * New for NCDATABASE)

(DEFINEQ

(NC.NoteFileFromUID
  (LAMBDA (UID)                                            (* pmi: "23-Nov-87 14:03")

          (* * Recover the notefile with given UID by looking it up in the notefile hash table.)


    (DECLARE (GLOBALVARS NC.NoteFilesHashArray))
    (AND UID (GETHASH UID NC.NoteFilesHashArray))))
)
(* * Install the altered History card type)

(NCHist.AddHistoryCard)
(PUTPROPS PMIPATCH066 COPYRIGHT ("Xerox Corporation" 1987))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (6513 7332 (NCP.CoerceToInterestedWindow 6523 . 6836) (NCP.NewCardP 6838 . 7095) (
NCP.NoteFileAddProp 7097 . 7330)) (7370 15324 (NCHist.AddHistoryCard 7380 . 8512) (
NCHist.HistoryCardMakeFn 8514 . 11181) (NCHist.HistoryCardWhenSavedFn 11183 . 12431) (
NCHist.NoteFileWhenOpenedFn 12433 . 13329) (NCHist.HistoricizeNoteFile 13331 . 14961) (
NCHist.CreateHistoryCardTitle 14963 . 15322)) (18319 33899 (NCHist.CreateHistoryDate 18329 . 18819) (
NCHist.ComputeHistory 18821 . 23062) (NCHist.GetLogEventFromStream 23064 . 23590) (
NCHist.ProcessLogEvent 23592 . 23904) (NCHist.ChangeHistoryEventSpecs 23906 . 24658) (
NCHist.AskHistoryEventSpecs 24660 . 27679) (NCHist.InitializeHistoryEventsSpecsStylesheet 27681 . 
29081) (NCHist.InitializeHistoryEventHashArray 29083 . 30916) (NCHist.InitializeLogEventFnHashArray 
30918 . 32962) (NCHist.ConvertPointersToLinks 32964 . 33421) (NCHist.TurnLoggingOn 33423 . 33658) (
NCHist.TurnLoggingOff 33660 . 33897)) (33957 35385 (NCHist.CreateLinkEventsMenuItemsFn 33967 . 34147) 
(NCHist.CreateLinkEventsDefaultMenuChoicesFn 34149 . 34415) (NCHist.CreateLinkEventsMenuChoicesFn 
34417 . 34674) (NCHist.DeleteLinkEventsMenuItemsFn 34676 . 34856) (
NCHist.DeleteLinkEventsDefaultMenuChoicesFn 34858 . 35124) (NCHist.DeleteLinkEventsMenuChoicesFn 35126
 . 35383)) (35451 49412 (NCHist.EditCard.BeginDisplayFn 35461 . 35546) (NCHist.EditCard.EndDisplayFn 
35548 . 36289) (NCHist.QuitCard.BeginDisplayFn 36291 . 36395) (NCHist.QuitCard.EndDisplayFn 36397 . 
37207) (NCHist.MakeCard.BeginDisplayFn 37209 . 37418) (NCHist.MakeCard.EndDisplayFn 37420 . 38542) (
NCHist.GetNewCardDisplayFn 38544 . 39525) (NCHist.DelCardDisplayFn 39527 . 39823) (
NCHist.CacheCardDisplayFn 39825 . 40039) (NCHist.UncacheCardDisplayFn 40041 . 40259) (
NCHist.SaveCard.BeginDisplayFn 40261 . 40346) (NCHist.SaveCard.EndDisplayFn 40348 . 40566) (
NCHist.PutLinksDisplayFn 40568 . 40788) (NCHist.PutMainCardDataDisplayFn 40790 . 41789) (
NCHist.PutPropListDisplayFn 41791 . 42791) (NCHist.PutTitleDisplayFn 42793 . 44120) (
NCHist.AssignTitle.BeginDisplayFn 44122 . 44412) (NCHist.AssignTitle.EndDisplayFn 44414 . 44630) (
NCHist.MakeLinkDisplayFn 44632 . 45997) (NCHist.DelLinkDisplayFn 45999 . 47363) (
NCHist.RecomputeBrowser.BeginDisplayFn 47365 . 47458) (NCHist.RecomputeBrowser.EndDisplayFn 47460 . 
48217) (NCHist.RelayoutBrowser.BeginDisplayFn 48219 . 48311) (NCHist.RelayoutBrowser.EndDisplayFn 
48313 . 49062) (NCHist.AddCardTypeDisplayFn 49064 . 49313) (NCHist.StartLoggingDisplayFn 49315 . 49410
)) (49580 52191 (NCCollab.OpenNoteFileFn 49590 . 52189)) (52602 52952 (NC.NoteFileFromUID 52612 . 
52950)))))
STOP