(FILECREATED "16-Jan-86 19:05:42" {QV}<NOTECARDS>1.3K>FGHPATCH014.;3 13810 changes to: (FNS NC.OpenDatabaseFile NC.BuildHashArray NC.GetHashArray) (VARS FGHPATCH014COMS) previous date: "16-Jan-86 17:49:31" {QV}<NOTECARDS>1.3K>FGHPATCH014.;1) (* Copyright (c) 1986 by Xerox Corporation. All rights reserved.) (PRETTYCOMPRINT FGHPATCH014COMS) (RPAQQ FGHPATCH014COMS ((* * Redefined from NCDATABASE to change when Special Cards are cached during open) (FNS NC.OpenDatabaseFile NC.BuildHashArray NC.GetHashArray NC.GetSpecialCards) (* * Redefined from NCCARDS to insure that the top level cards are always cached in an active but not necessarly displayed state) (FNS NC.QuitCard))) (* * Redefined from NCDATABASE to change when Special Cards are cached during open) (DEFINEQ (NC.OpenDatabaseFile (LAMBDA (NoteFileOrFileName Access Don'tCacheTypesAndTitlesFlg QuietFlg Don'tCreateFlg Convertw/oConfirmFlg Don'tCreateArrayFlg Don'tTruncateFlg Don'tCreateInterfaceFlg Don'tGetSpecialCardsFlg) (* fgh: "16-Jan-86 18:55") (* * Open an already existing NoteFile and return a NoteFile object) (* * rht 8/7/84: For nonexistent files, asks user whether to create unless Don'tCreateFlg is non-nil.) (* * rht 1/9/85: Checks NC.UncachingNotCompleted global var. If non-nil, then previous notefile died unnaturally, so we first clear junk off the IDs.) (* * rht 8/6/85: Added Don'tTruncateFlg, which, if on, prevents the check for truncation.) (* * fgh 10/16/85 Updated to use new cacheing scheme.) (* * kirk 10/29/85: Now does cacheing of types and titles as background process.) (* * fkr 11/8/85: Converted from Streams to NoteFile object.) (* * kirk 30Nov85 Added a check for correct version number.) (* * rht 12/6/85: Moved Kirk's above patch to NC.CheckForNeededConversion and modified somewhat. Added check for plausible header.) (* * rht 1/8/86: Now reuses old notefile object if there is one for this filename.) (* * fgh 1/13/86: Fixed bug with returning File Name with embedded call to CreateDatabaseFile. Now just calls OpenDatabaseFile recursively using result of CreateDatabaseFile.) (* * fgh 1/16/86 Folded the cacheing of the special cards into BuildHashArray instead of making it a separate function after the hash array is already read in.) (PROG (NoteFile FileName Name Stream NewStream Card CardTotal) (OR Access (SETQ Access (QUOTE BOTH))) (SETQ FileName (COND ((type? NoteFile NoteFileOrFileName) (SETQ NoteFile NoteFileOrFileName) (fetch (NoteFile FullFileName) of NoteFileOrFileName)) (T NoteFileOrFileName))) (if (NOT (OR FileName (SETQ FileName (NC.DatabaseFileName "Name of NoteFile to open:" " -- " T)))) then (RETURN NIL)) (if (OPENP FileName) then (NC.PrintMsg NIL T FileName " is an already open file." (CHARACTER 13)) (RETURN NIL)) (if (NOT (SETQ Name (INFILEP FileName))) then (COND (Don'tCreateFlg (NC.PrintMsg NIL T "Couldn't find NoteFile " FileName "." (CHARACTER 13)) (RETURN NIL)) ((NC.YesP (NC.AskUser (CONCAT "Unable to find NoteFile " FileName "." (CHARACTER 13) "Want to create new NoteFile by that name? ") " -- " "Yes" T NIL T NIL T)) (SETQ NoteFile (NC.CreateDatabaseFile FileName NIL "Opening NoteFile" T)) (if (NOT (type? NoteFile NoteFile)) then (NC.PrintMsg NIL T "Unable to create Notefile " FileName "." (CHARACTER 13)) (RETURN NIL) else (RETURN (NC.OpenDatabaseFile NoteFile Access Don'tCacheTypesAndTitlesFlg QuietFlg Don'tCreateFlg Convertw/oConfirmFlg Don'tCreateArrayFlg Don'tTruncateFlg Don'tCreateInterfaceFlg Don'tGetSpecialCardsFlg)))) (T (RETURN NIL)))) (OR QuietFlg (NC.PrintMsg NIL T "Opening ... " (CHARACTER 13))) (if (NULL (SETQ Stream (CAR (ERSETQ (OPENSTREAM Name Access (QUOTE OLD) (QUOTE ((TYPE BINARY)))))))) then (NC.PrintMsg NIL T "Couldn't open " FileName "." (CHARACTER 13)) (RETURN NIL)) (* Use existing notefile object if there is one for this file name.) (OR (type? NoteFile NoteFile) (SETQ NoteFile (OR (NC.NoteFileFromFileName FileName) (create NoteFile)))) (replace (NoteFile Stream) of NoteFile with Stream) (replace (NoteFile FullFileName) of NoteFile with (FULLNAME Stream)) (NC.SetMonitor NoteFile (CREATE.MONITORLOCK (MKATOM (CONCAT Name ":LOCK")))) (NC.GetNoteFileHeader NoteFile) (* See if notefile is out of date. If so, convert to current version.) (if (NOT (NC.CheckForNeededConversion NoteFile Convertw/oConfirmFlg)) then (CLOSEF (fetch (NoteFile Stream) of NoteFile)) (NC.PrintMsg NIL T "Open cancelled.") (RETURN NIL)) (* See if notefile header seems reasonable. If not, bail out.) (if (NOT (NC.PlausibleNoteFileHeaderP NoteFile)) then (NC.PrintMsg NIL NIL "Notefile has bad header. Please see a NoteCards wizard." (CHARACTER 13) "Open cancelled.") (RETURN NIL)) (COND ((NULL Don'tTruncateFlg) (* Can either bail out entirely or run inspector and then bail out.) (SELECTQ (SETQ NewStream (NC.CheckForNeededTruncation NoteFile Access)) (ABORT (CLOSEF Stream) (NC.PrintMsg NIL T "Open cancelled.") (RETURN NIL)) (ABORTANDINSPECT (CLOSEF Stream) (NC.ScavengerPhase1 Name) (RETURN NIL)) NIL) (AND (STREAMP NewStream) (replace (NoteFile Stream) of NoteFile with NewStream)))) (* * Stash the notefile in the global notefiles hash array.) (NC.StoreNoteFile NoteFile) (* * Build the hash array and cache the special cards if necessary) (OR Don'tCreateArrayFlg (NC.BuildHashArray NoteFile NIL Don'tGetSpecialCardsFlg)) (OR Don'tGetSpecialCardsFlg (NC.GetSpecialCards NoteFile)) (* * Make sure the NF can't be closed by CLOSEALL) (WHENCLOSE (fetch (NoteFile Stream) of NoteFile) (QUOTE CLOSEALL) (QUOTE NO)) (COND ((NULL Don'tCacheTypesAndTitlesFlg) (* Cache all of the titles in this database) (replace (NoteFile CachingProcess) of NoteFile with (ADD.PROCESS (LIST (FUNCTION NC.CacheTypesAndTitles) NoteFile))))) (COND ((NULL Don'tCreateInterfaceFlg) (* Make an interface menu for this notefile.) (NC.SetUpNoteFileInterface NoteFile))) (AND (NULL QuietFlg) (NC.PrintMsg NIL T "Opened " (FULLNAME Stream) (CHARACTER 13))) (SETQ NC.LastNoteFileOpened NoteFile) (RETURN NoteFile)))) (NC.BuildHashArray (LAMBDA (NoteFile QuietFlg Don'tGetSpecialCardsFlg) (* fgh: "16-Jan-86 17:48") (* * Create a hash array and fill it from the index array on NoteFile.) (* * fgh 1/16/86 Added Don'tGetSpecialCardsFlg parameter to pass to NC.GetHashArray) (replace (NoteFile HashArray) of NoteFile with (NC.CreateUIDHashArray (fetch (NoteFile HashArraySize) of NoteFile))) (NC.GetHashArray NoteFile QuietFlg NIL Don'tGetSpecialCardsFlg))) (NC.GetHashArray (LAMBDA (NoteFile QuietFlg OperationMsg Don'tGetSpecialCardsFlg) (* fgh: "16-Jan-86 17:48") (* * Fill NoteFile's hash array by reading from the index on NoteFile.) (* * rht 12/6/85: Fixed to build free list of IndexNum's.) (* * rht 12/7/85: Minor addition of print statement in front of loop.) (* * fgh 1/16/86 Now special cards are stashed on the NF object as they are read in rather than in a separate operation later on.) (OR OperationMsg (SETQ OperationMsg "")) (WITH.MONITOR (NC.FetchMonitor NoteFile) (LET ((Stream (fetch (NoteFile Stream) of NoteFile)) (CardTotal (SUB1 (fetch (NoteFile NextIndexNum) of NoteFile))) IndexNumsFreeList) (OR QuietFlg (NC.PrintMsg NIL T OperationMsg "Reading in hash array: item number " 1 " out of " CardTotal "." (CHARACTER 13))) (SETFILEPTR Stream (CONSTANT (fetch (NoteFileVersion NoteFileHeaderSize) of (NC.FetchCurrentVersionObject)))) (NC.PrintMsg NIL T OperationMsg "Reading in hash array: item number " 1 " out of " CardTotal "." (CHARACTER 13)) (for IndexNum from 1 to CardTotal bind Card eachtime (BLOCK) do (OR QuietFlg (AND (ZEROP (REMAINDER IndexNum 100)) (NC.PrintMsg NIL T OperationMsg "Reading in hash array: item number " IndexNum " out of " CardTotal "." (CHARACTER 13)))) (SETQ Card (NC.ReadIndexEntry NoteFile)) (if (EQ (fetch (Card Status) of Card) (QUOTE FREE)) then (push IndexNumsFreeList IndexNum)) (* * Stash the special cards on the NF object) (AND (NULL Don'tGetSpecialCardsFlg) (LESSP IndexNum 5) (SELECTQ IndexNum (1 (replace (NoteFile TableOfContentsCard) of NoteFile with Card)) (2 (replace (NoteFile OrphansCard) of NoteFile with Card)) (3 (replace (NoteFile ToBeFiledCard) of NoteFile with Card)) (4 (replace (NoteFile LinkLabelsCard) of NoteFile with Card)) NIL))) (replace (NoteFile IndexNumsFreeList) of NoteFile with IndexNumsFreeList) )))) (NC.GetSpecialCards (LAMBDA (NoteFile) (* fgh: "16-Jan-86 18:10") (* * fgh 1/16/86 Activate but don't display the special cards. This essentially caches them for fast access.) (NCP.ActivateCards (LIST (fetch (NoteFile TableOfContentsCard) of NoteFile) (fetch (NoteFile OrphansCard) of NoteFile) (fetch (NoteFile ToBeFiledCard) of NoteFile) (fetch (NoteFile LinkLabelsCard) of NoteFile))))) ) (* * Redefined from NCCARDS to insure that the top level cards are always cached in an active but not necessarly displayed state) (DEFINEQ (NC.QuitCard (LAMBDA (CardIdentifier CallCloseWFlg DontSaveFlg) (* fgh: "16-Jan-86 18:18") (* * Force note card specified by ID to quit or stop) (* * rht 2/9/85: New arg DontSaveFlg prevents NC.CardSaveFn from being called. Used when aborting a card. This is NOT equivalent to NC.QuitWithoutSaving.) (* * rht 6/25/85: Now moves card off screen before saving if NC.CloseCardsOffScreenFlg is non-nil.) (* * rht 6/25/85: Brought the insure proper filing check back here from NC.CardSaveFn. Bails out if user cancelled operation inside of NC.InsureProperFiling) (* * fgh 11/11/85: Updated to handle CardID and CardInfo objects.) (* * fgh 1/16/86 Put in code to insure that if one of the TopLevelCards is quit then it is reactivated immedialtely to make sure it stays cached for fast access.) (PROG ((Card (NC.CoerceToCard CardIdentifier)) Window) (SETQ Window (NC.FetchWindow Card)) (* The window not being open should mean that it's shrunken. If so, expand it.) (COND ((NOT (OPENWP Window)) (EXPANDW Window))) (OR DontSaveFlg (COND ((EQ (NC.InsureProperFiling Card) (QUOTE CANCELLED)) (RETURN (QUOTE DON'T))))) (COND ((AND Window NC.CloseCardsOffScreenFlg) (COND ((NOT (NC.FetchSavedRegion Card)) (NC.SetSavedRegion Card (WINDOWPROP Window (QUOTE REGION))))) (MOVEW Window 1500 1500))) (OR DontSaveFlg (NC.CardSaveFn Card NC.CloseCardsOffScreenFlg)) (AND Window (WINDOWDELPROP Window (QUOTE CLOSEFN) (FUNCTION NC.QuitCard))) (RETURN (PROG1 (APPLY* (NC.QuitCardFn (NC.RetrieveType Card)) Card) (AND CallCloseWFlg Window (CLOSEW Window)) (* * if this is one of the top level cards, then make sure it stays cached) (if (NC.TopLevelCardP Card) then (NCP.ActivateCards Card))))))) ) (PUTPROPS FGHPATCH014 COPYRIGHT ("Xerox Corporation" 1986)) (DECLARE: DONTCOPY (FILEMAP (NIL (848 11417 (NC.OpenDatabaseFile 858 . 7787) (NC.BuildHashArray 7789 . 8336) ( NC.GetHashArray 8338 . 10898) (NC.GetSpecialCards 10900 . 11415)) (11555 13728 (NC.QuitCard 11565 . 13726))))) STOP