(FILECREATED "16-Oct-85 19:21:59" {QV}<NOTECARDS>1.3K>FGHCACHE.;13 41952 changes to: (FNS NC.SetScale NC.OpenDatabaseFile NC.GetNewID NC.SaveDirtyCards NC.InitializeSpecialCards NC.SetNewCardFlg NC.ActivateCard NC.SetFromLinks NC.SetGlobalLinks NC.SetLinksDirtyFlg NC.SetPropList NC.SetRegion NC.SetSavedRegion NC.SetRegionViewed NC.SetTitle NC.SetToLinks NC.SetType NC.SetTitleDirtyFlg NC.SetPropListDirtyFlg NC.SetSubstanceDirtyFlg NC.SetBeingDeletedFlg NC.SetTitleDate NC.SetItemDate NC.SetPropListDate NC.SetLinksDate NC.SetSubstance NC.FetchNewCardFlg NC.ActiveCardP NC.FetchFromLinks NC.FetchGlobalLinks NC.FetchLinksDirtyFlg NC.FetchPropList NC.FetchRegion NC.FetchSavedRegion NC.FetchRegionViewed NC.FetchScale NC.FetchTitle NC.FetchToLinks NC.FetchType NC.FetchTitleDirtyFlg NC.FetchPropListDirtyFlg NC.FetchSubstanceDirtyFlg NC.FetchBeingDeletedFlg NC.FetchTitleDate NC.FetchItemDate NC.FetchPropListDate NC.FetchLinksDate NC.FetchSubstance NC.DeactivateCard NC.MakeNoteCard NC.FetchCacheArray NC.BuildCacheArray NC.CloseDatabaseFile) (VARS FGHCACHECOMS) previous date: "16-Oct-85 11:01:35" {QV}<NOTECARDS>1.3K>FGHCACHE.;8) (* Copyright (c) 1985 by Xerox Corporation. All rights reserved.) (PRETTYCOMPRINT FGHCACHECOMS) (RPAQQ FGHCACHECOMS ((* * New Stuff) (RECORDS NoteCardCache) (FNS NC.FetchCardCache NC.FetchCacheArray NC.InsureIntegerDate NC.SetCacheUserProp NC.FetchCacheUserProp NC.BuildCacheArray NC.IncreaseCacheArray NC.SetCardCache) (* * Redefined from NCCARDS) (FNS NC.SetNewCardFlg NC.ActivateCard NC.SetFromLinks NC.SetGlobalLinks NC.SetLinksDirtyFlg NC.SetPropList NC.SetRegion NC.SetSavedRegion NC.SetRegionViewed NC.SetScale NC.SetTitle NC.SetToLinks NC.SetType NC.SetTitleDirtyFlg NC.SetPropListDirtyFlg NC.SetSubstanceDirtyFlg NC.SetBeingDeletedFlg NC.SetTitleDate NC.SetItemDate NC.SetPropListDate NC.SetLinksDate NC.SetSubstance NC.DeactivateCard) (FNS NC.FetchNewCardFlg NC.ActiveCardP NC.FetchFromLinks NC.FetchGlobalLinks NC.FetchLinksDirtyFlg NC.FetchPropList NC.FetchRegion NC.FetchSavedRegion NC.FetchRegionViewed NC.FetchScale NC.FetchTitle NC.FetchToLinks NC.FetchType NC.FetchTitleDirtyFlg NC.FetchPropListDirtyFlg NC.FetchSubstanceDirtyFlg NC.FetchBeingDeletedFlg NC.FetchTitleDate NC.FetchItemDate NC.FetchPropListDate NC.FetchLinksDate NC.FetchSubstance) (FNS NC.MakeNoteCard) (* * Redefined from NCDATABASE) (FNS NC.GetNewID NC.CloseDatabaseFile NC.OpenDatabaseFile NC.InitializeSpecialCards NC.SaveDirtyCards))) (* * New Stuff) [DECLARE: EVAL@COMPILE (DATATYPE NoteCardCache (ID Substance Title Type ToLinks FromLinks GlobalLinks PropList Region SavedRegion UserData (ItemDate FIXP) (LinksDate FIXP) (TitleDate FIXP) (PropListDate FIXP) (ActiveCardFlg FLAG) (LinksDirtyFlg FLAG) (TitleDirtyFlg FLAG) (PropListDirtyFlg FLAG) (SubstanceDirtyFlg FLAG) (NewCardFlg FLAG) (BeingDeletedFlg FLAG))) ] (/DECLAREDATATYPE (QUOTE NoteCardCache) (QUOTE (POINTER POINTER POINTER POINTER POINTER POINTER POINTER POINTER POINTER POINTER POINTER FIXP FIXP FIXP FIXP FLAG FLAG FLAG FLAG FLAG FLAG FLAG)) (QUOTE ((NoteCardCache 0 POINTER) (NoteCardCache 2 POINTER) (NoteCardCache 4 POINTER) (NoteCardCache 6 POINTER) (NoteCardCache 8 POINTER) (NoteCardCache 10 POINTER) (NoteCardCache 12 POINTER) (NoteCardCache 14 POINTER) (NoteCardCache 16 POINTER) (NoteCardCache 18 POINTER) (NoteCardCache 20 POINTER) (NoteCardCache 22 FIXP) (NoteCardCache 24 FIXP) (NoteCardCache 26 FIXP) (NoteCardCache 28 FIXP) (NoteCardCache 20 (FLAGBITS . 0)) (NoteCardCache 20 (FLAGBITS . 16)) (NoteCardCache 20 (FLAGBITS . 32)) (NoteCardCache 20 (FLAGBITS . 48)) (NoteCardCache 20 (FLAGBITS . 64)) (NoteCardCache 20 (FLAGBITS . 80)) (NoteCardCache 20 (FLAGBITS . 96)))) (QUOTE 30)) (DEFINEQ (NC.FetchCardCache (LAMBDA (ID CacheArray) (* fgh: "16-Oct-85 00:18") (* * Retrun the card cache for card ID from CacheArray. Create a card cache if one doesn't exist.) (LET ((NumericalID (COND ((FIXP ID)) (T (NC.NumberFromID ID))))) (COND ((ELT CacheArray NumericalID)) (T (SETA CacheArray NumericalID (create NoteCardCache ID ← NumericalID))))))) (NC.FetchCacheArray (LAMBDA (DatabaseStream CacheArray) (* fgh: "16-Oct-85 14:54") (* * Return the cache array corresponding to DatabaseStream, unless CacheArray is a cache array in which case just retrun it.) (COND ((AND (ARRAYP CacheArray) (EQ (ELT CacheArray 0) (QUOTE Active))) (* * CacheArray is a pointer to a still valid cache array -- i.e., one with Active in its zeroth position.) CacheArray) ((AND (STREAMP DatabaseStream) (ARRAYP (STREAMPROP DatabaseStream (QUOTE NCCACHEARRAY))))) ((AND (STREAMP PSA.Database) (ARRAYP (STREAMPROP PSA.Database (QUOTE NCCACHEARRAY))))) (T (NC.ReportError NIL "No cache array could be found."))))) (NC.InsureIntegerDate (LAMBDA (Date) (* fgh: "16-Oct-85 01:16") (* * Convert a date to IDATE format if necessary) (COND ((NULL Date) 0) ((FIXP Date)) ((STRINGP Date) (IDATE Date)) (T (NC.ReportError NIL "Unknown date format"))))) (NC.SetCacheUserProp (LAMBDA (ID Prop Value DatabaseStream CacheArray) (* fgh: "15-Oct-85 22:47") (* * Set the value of Prop to Value on the UserData prop list in the cache for card ID.) (LET (CardCache UserDataPropList) (SETQ UserDataPropList (fetch (NoteCardCache UserData) of (SETQ CardCache (NC.FetchCardCache ID ( NC.FetchCacheArray DatabaseStream CacheArray))))) (COND (UserDataPropList (LISTPUT UserDataPropList Prop Value)) (T (replace (NoteCardCache UserData) of CardCache with (LIST Prop Value))))))) (NC.FetchCacheUserProp (LAMBDA (ID Prop DatabaseStream CacheArray) (* fgh: "15-Oct-85 23:17") (* * Fetch the value of Prop to Value on the UserData prop list in the cache for card ID.) (LET (UserDataPropList) (SETQ UserDataPropList (fetch (NoteCardCache UserData) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray)))) (AND UserDataPropList (LISTGET UserDataPropList Prop))))) (NC.BuildCacheArray (LAMBDA (DatabaseStream) (* fgh: "16-Oct-85 14:52") (* * Build the cache array) (LET (CacheArray (NextIDNum (STREAMPROP DatabaseStream (QUOTE NCNEXTIDNUM)))) (STREAMPROP DatabaseStream (QUOTE NCCACHEARRAY) (SETQ CacheArray (ARRAY (IMAX NC.DefaultIndexSizeInEntries (FIX (TIMES 1.5 NextIDNum))) (QUOTE POINTER) NIL 0))) (SETA CacheArray 0 (QUOTE Active)) CacheArray))) (NC.IncreaseCacheArray (LAMBDA (DatabaseStream) (* fgh: "16-Oct-85 10:58") (* * Make a new array half again as big and copy the contents from the old one. But don't make the new array any bigger than the current index size.) (LET ((Array (STREAMPROP DatabaseStream (QUOTE NCCACHEARRAY))) OldSize NewArray) (SETQ OldSize (ARRAYSIZE Array)) (SETQ NewArray (ARRAY (IMIN NC.IndexSizeInEntries (FIX (TIMES 1.5 OldSize))) (QUOTE POINTER) NIL 0)) (for i from 0 to OldSize do (SETA NewArray i (ELT Array i))) (STREAMPROP DatabaseStream (QUOTE NCCACHEARRAY) NewArray) (* * Invalidate old array by removing the database stream from the 0th position) (SETA Array 0 NIL) NewArray))) (NC.SetCardCache (LAMBDA (ID CacheArray CardCache) (* fgh: "15-Oct-85 23:45") (* * Set the card cache for card ID from CacheArray) (LET ((NumericalID (COND ((FIXP ID)) (T (NC.NumberFromID ID))))) (SETA CacheArray NumericalID CardCache)))) ) (* * Redefined from NCCARDS) (DEFINEQ (NC.SetNewCardFlg (LAMBDA (ID Value DatabaseStream CacheArray) (* fgh: "15-Oct-85 23:01") (* Set the new card flg of ID to Value) (replace (NoteCardCache NewCardFlg) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray)) with Value))) (NC.ActivateCard (LAMBDA (ID DatabaseStream CacheArray) (* fgh: "15-Oct-85 22:33") (* * Set the active card flg for ID) (replace (NoteCardCache ActiveCardFlg) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray)) with T))) (NC.SetFromLinks (LAMBDA (ID Links DatabaseStream CacheArray) (* fgh: "15-Oct-85 22:34") (* * Cahce the from links for ID) (replace (NoteCardCache FromLinks) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray)) with Links))) (NC.SetGlobalLinks (LAMBDA (ID GlobalLinks DatabaseStream CacheArray) (* fgh: "15-Oct-85 22:35") (* * Cache the global links of ID) (replace (NoteCardCache GlobalLinks) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray)) with GlobalLinks))) (NC.SetLinksDirtyFlg (LAMBDA (ID Value DatabaseStream CacheArray) (* fgh: "15-Oct-85 22:36") (* * Set the flag indicating the links cache is dirty) (replace (NoteCardCache LinksDirtyFlg) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray)) with Value))) (NC.SetPropList (LAMBDA (ID PropList DatabaseStream CacheArray) (* fgh: "15-Oct-85 22:37") (* * Cache the prop list of ID) (replace (NoteCardCache PropList) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray)) with PropList))) (NC.SetRegion (LAMBDA (ID Region DatabaseStream CacheArray) (* fgh: "15-Oct-85 22:38") (* * Cache the region of ID) (replace (NoteCardCache Region) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray)) with Region))) (NC.SetSavedRegion (LAMBDA (ID Region DatabaseStream CacheArray) (* fgh: "15-Oct-85 22:40") (* * Cache the saved region of card ID) (replace (NoteCardCache SavedRegion) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray)) with Region))) (NC.SetRegionViewed (LAMBDA (ID RegionValue DatabaseStream CacheArray) (* fgh: "16-Oct-85 00:14") (* * For sketch cards -- save the cahce the region viewd on the cache UserData prop list) (NC.SetCacheUserProp ID (QUOTE RegionViewed) DatabaseStream CacheArray))) (NC.SetScale (LAMBDA (ID ScaleValue DatabaseStream CacheArray) (* fgh: "16-Oct-85 19:20") (* * For sketch cards -- cache the scale on the cache UserData prop list) (NC.SetCacheUserProp ID (QUOTE Scale) DatabaseStream CacheArray))) (NC.SetTitle (LAMBDA (ID Title DatabaseStream CacheArray) (* fgh: "15-Oct-85 22:50") (* * Cache the title for card ID) (replace (NoteCardCache Title) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray)) with Title))) (NC.SetToLinks (LAMBDA (ID Links DatabaseStream CacheArray) (* fgh: "15-Oct-85 22:51") (* * Cache the to links for card ID) (replace (NoteCardCache ToLinks) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray)) with Links))) (NC.SetType (LAMBDA (ID NoteCardType DatabaseStream CacheArray) (* fgh: "15-Oct-85 22:52") (* * Cache the type of ID) (replace (NoteCardCache Type) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray)) with NoteCardType))) (NC.SetTitleDirtyFlg (LAMBDA (ID Value DatabaseStream CacheArray) (* fgh: "15-Oct-85 22:52") (* * Set the title cahce is dirty flag) (replace (NoteCardCache TitleDirtyFlg) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray)) with Value))) (NC.SetPropListDirtyFlg (LAMBDA (ID Value DatabaseStream CacheArray) (* fgh: "15-Oct-85 22:53") (* * Set the prop list cache dirty flg) (replace (NoteCardCache PropListDirtyFlg) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray)) with Value))) (NC.SetSubstanceDirtyFlg (LAMBDA (ID Value DatabaseStream CacheArray) (* fgh: "15-Oct-85 22:54") (* * Set the substance cahce dirty flg) (replace (NoteCardCache SubstanceDirtyFlg) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray)) with Value))) (NC.SetBeingDeletedFlg (LAMBDA (ID Value DatabaseStream CacheArray) (* fgh: "15-Oct-85 22:55") (* * Set the being deleted flag in the cache) (replace (NoteCardCache BeingDeletedFlg) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray)) with Value))) (NC.SetTitleDate (LAMBDA (ID Date DatabaseStream CacheArray) (* fgh: "16-Oct-85 01:27") (* * Set the title date in the cahce for card ID) (replace (NoteCardCache TitleDate) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray)) with (NC.InsureIntegerDate Date)) Date)) (NC.SetItemDate (LAMBDA (ID Date DatabaseStream CacheArray) (* fgh: "16-Oct-85 01:27") (* * Set the item date in the cache for ID) (replace (NoteCardCache ItemDate) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray)) with (NC.InsureIntegerDate Date)) Date)) (NC.SetPropListDate (LAMBDA (ID Date DatabaseStream CacheArray) (* fgh: "16-Oct-85 01:27") (* * Set the prop list date in the cache for ID) (replace (NoteCardCache PropListDate) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray)) with (NC.InsureIntegerDate Date)) Date)) (NC.SetLinksDate (LAMBDA (ID Date DatabaseStream CacheArray) (* fgh: "16-Oct-85 01:27") (* * Set the links date in the cache for card ID) (replace (NoteCardCache LinksDate) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray)) with (NC.InsureIntegerDate Date)) Date)) (NC.SetSubstance (LAMBDA (ID Substance DatabaseStream CacheArray) (* fgh: "16-Oct-85 01:31") (* * Set the cached substance of card ID to be substance) (replace (NoteCardCache Substance) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray)) with Substance))) (NC.DeactivateCard (LAMBDA (ID DeleteTypeAndTitleFlg DatabaseStream CacheArray) (* fgh: "16-Oct-85 00:33") (* * Remove all the information from the prop list of the NoteCard ID, except for the title which usually statys cached.) (* * rht 7/9/85: Now also removes the new date properties.) (* * fgh 10/15/85 altered to use new caching mechanism) (LET ((CardCache (NC.FetchCardCache ID (SETQ CacheArray (NC.FetchCacheArray DatabaseStream CacheArray))))) (COND (DeleteTypeAndTitleFlg (NC.SetCardCache ID CacheArray NIL)) (T (NC.SetCardCache ID CacheArray (create NoteCardCache Type ←(fetch (NoteCardCache Type) of CardCache) Title ←(fetch (NoteCardCache Title) of CardCache)))) )))) ) (DEFINEQ (NC.FetchNewCardFlg (LAMBDA (ID DatabaseStream CacheArray) (* fgh: "15-Oct-85 23:07") (* Return the value of the new card flg of ID) (fetch (NoteCardCache NewCardFlg) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray))))) (NC.ActiveCardP (LAMBDA (ID DatabaseStream CacheArray) (* fgh: "16-Oct-85 00:38") (* * If the active card flg is set in the cache for ID, the return ID's type. Otherwise return NIL.) (AND ID (fetch (NoteCardCache ActiveCardFlg) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray))) (NC.FetchType ID DatabaseStream CacheArray)))) (NC.FetchFromLinks (LAMBDA (ID DatabaseStream CacheArray) (* fgh: "15-Oct-85 23:10") (* * Fetch ID's links from the cache) (fetch (NoteCardCache FromLinks) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray))))) (NC.FetchGlobalLinks (LAMBDA (ID DatabaseStream CacheArray) (* fgh: "15-Oct-85 23:11") (* * Fetch IDs global links from the cache) (fetch (NoteCardCache GlobalLinks) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray))))) (NC.FetchLinksDirtyFlg (LAMBDA (ID DatabaseStream CacheArray) (* fgh: "15-Oct-85 23:12") (* * fetch IDs links dirty flag fom the cache) (fetch (NoteCardCache LinksDirtyFlg) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray))))) (NC.FetchPropList (LAMBDA (ID DatabaseStream CacheArray) (* fgh: "15-Oct-85 23:12") (* * fetych IDs prop list from the cache) (fetch (NoteCardCache PropList) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray))))) (NC.FetchRegion (LAMBDA (ID DatabaseStream CacheArray) (* fgh: "15-Oct-85 23:13") (* * fetch IDs region from the cache) (fetch (NoteCardCache Region) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray))))) (NC.FetchSavedRegion (LAMBDA (ID DatabaseStream CacheArray) (* fgh: "15-Oct-85 23:14") (* * fetch IDs saved region from the cache) (fetch (NoteCardCache SavedRegion) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray))))) (NC.FetchRegionViewed (LAMBDA (ID DatabaseStream CacheArray) (* fgh: "15-Oct-85 23:18") (* * For sketch cards -- fetch from the UserData prop list the region viewed property) (NC.FetchCacheUserProp ID (QUOTE RegionViewed) DatabaseStream CacheArray))) (NC.FetchScale (LAMBDA (ID DatabaseStream CacheArray) (* fgh: "15-Oct-85 23:18") (* * For sketch cards -- fetch from the UserData prop list the region viewed property) (NC.FetchCacheUserProp ID (QUOTE Scale) DatabaseStream CacheArray))) (NC.FetchTitle (LAMBDA (ID DatabaseStream CacheArray) (* fgh: "15-Oct-85 23:19") (* * Fetch the title from IDs cache) (fetch (NoteCardCache Title) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray))))) (NC.FetchToLinks (LAMBDA (ID DatabaseStream CacheArray) (* fgh: "15-Oct-85 23:19") (* * fetch the to links from IDs cache) (fetch (NoteCardCache ToLinks) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray))))) (NC.FetchType (LAMBDA (ID DatabaseStream CacheArray) (* fgh: "15-Oct-85 23:20") (* * Fetch the note card type from IDs cache) (fetch (NoteCardCache Type) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray))))) (NC.FetchTitleDirtyFlg (LAMBDA (ID DatabaseStream CacheArray) (* fgh: "15-Oct-85 23:21") (* * fetch the cached title dirty flag) (fetch (NoteCardCache TitleDirtyFlg) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray))))) (NC.FetchPropListDirtyFlg (LAMBDA (ID DatabaseStream CacheArray) (* fgh: "15-Oct-85 23:21") (* * Fetch the prop liost list cache dirty flag) (fetch (NoteCardCache PropListDirtyFlg) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray))))) (NC.FetchSubstanceDirtyFlg (LAMBDA (ID DatabaseStream CacheArray) (* fgh: "15-Oct-85 23:22") (* * fetch the substance cache dirty flag) (fetch (NoteCardCache SubstanceDirtyFlg) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray))))) (NC.FetchBeingDeletedFlg (LAMBDA (ID DatabaseStream CacheArray) (* fgh: "16-Oct-85 00:23") (* * fetch IDs being deleted flag from the cache) (fetch (NoteCardCache BeingDeletedFlg) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray))))) (NC.FetchTitleDate (LAMBDA (ID DatabaseStream CacheArray DontConvertFlg) (* fgh: "16-Oct-85 01:18") (* * Fetch IDs title date from the cache and and convert to string format if necessary) (LET ((Date (fetch (NoteCardCache TitleDate) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray))))) (COND ((ZEROP Date) NIL) (DontConvertFlg Date) (T (GDATE Date)))))) (NC.FetchItemDate (LAMBDA (ID DatabaseStream CacheArray DontConvertFlg) (* fgh: "16-Oct-85 01:17") (* * Fetch IDs item date from the cache and and convert to string format if necessary) (LET ((Date (fetch (NoteCardCache ItemDate) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray))))) (COND ((ZEROP Date) NIL) (DontConvertFlg Date) (T (GDATE Date)))))) (NC.FetchPropListDate (LAMBDA (ID DatabaseStream CacheArray DontConvertFlg) (* fgh: "16-Oct-85 01:18") (* * Fetch IDs prop list date from the cache and and convert to string format if necessary) (LET ((Date (fetch (NoteCardCache PropListDate) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray) )))) (COND ((ZEROP Date) NIL) (DontConvertFlg Date) (T (GDATE Date)))))) (NC.FetchLinksDate (LAMBDA (ID DatabaseStream CacheArray DontConvertFlg) (* fgh: "16-Oct-85 01:18") (* * Fetch IDs links date from the cache and and convert to string format if necessary) (LET ((Date (fetch (NoteCardCache LinksDate) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray))))) (COND ((ZEROP Date) NIL) (DontConvertFlg Date) (T (GDATE Date)))))) (NC.FetchSubstance (LAMBDA (ID DatabaseStream CacheArray) (* fgh: "16-Oct-85 01:32") (* * Return the substance of card ID) (fetch (NoteCardCache Substance) of (NC.FetchCardCache ID (NC.FetchCacheArray DatabaseStream CacheArray))))) ) (DEFINEQ (NC.MakeNoteCard (LAMBDA (NoteCardType Title NoDisplayFlg TypeSpecificArgs ID DatabaseStream) (* fgh: "16-Oct-85 00:50") (* Make a new note card of type NoteCardType. If type note specified, ask the user.) (* * rht 2/1/85: Added call to NC.MarkCardDirty.) (* * fgh 10/15/85 Added extra DatabaseStream argument for use by caching mechanism) (OR (STREAMP DatabaseStream) (SETQ DatabaseStream PSA.Database)) (PROG (ReturnValue CopyID Window (CacheArray (NC.FetchCacheArray DatabaseStream))) (AND (SETQ NoteCardType (OR NoteCardType (NC.AskNoteCardType))) (RESETLST (RESETSAVE (CURSOR WAITINGCURSOR)) (OR (NC.IDP ID) (SETQ ID (NC.GetNewID DatabaseStream))) (NC.SetNewCardFlg ID T DatabaseStream CacheArray) (NC.ActivateCard ID DatabaseStream CacheArray) (OR (NC.FetchType ID DatabaseStream CacheArray) (NC.SetType ID NoteCardType DatabaseStream CacheArray)) (COND ((OR (NULL (ERSETQ (SETQ ReturnValue (APPLY* (NC.MakeCardFn NoteCardType) ID Title NoDisplayFlg TypeSpecificArgs)))) (NULL ReturnValue)) (NC.MarkCardDeleted ID DatabaseStream) (SETPROPLIST ID NIL)) (T (SETQ Window (WINDOWP ReturnValue)) (COND ((NULL (NC.FetchTitle ID)) (SETQ Title (NC.SetTitle ID (SETQ Title (COND ((STRINGP Title) Title) ((AND Title (OR (LITATOM Title) (NUMBERP Title))) (MKSTRING Title)) (T "Untitled"))) DatabaseStream CacheArray)) (AND Window (WINDOWPROP Window (QUOTE TITLE) Title))) (T (NC.SetTitle ID (MKSTRING (NC.FetchTitle ID)) DatabaseStream CacheArray))) (COND (Window (WINDOWADDPROP Window (QUOTE CLOSEFN) (FUNCTION NC.QuitCard) (QUOTE FIRST)) (WINDOWPROP Window (QUOTE NoteCardID) ID))) (NC.SetTitleDirtyFlg ID T DatabaseStream CacheArray) (* Reset the type in case of recursive calls change the type. Always want the highest level type in a recursive descent) (NC.SetType ID NoteCardType DatabaseStream CacheArray) (* Insure that a link ptr is set up during the first save) (NC.SetLinksDirtyFlg ID T DatabaseStream CacheArray) (NC.SetPropListDirtyFlg ID T DatabaseStream CacheArray) (* Mark that substance is dirty.) (NC.MarkCardDirty ID T DatabaseStream CacheArray))))) (RETURN ReturnValue)))) ) (* * Redefined from NCDATABASE) (DEFINEQ (NC.GetNewID (LAMBDA (DatabaseStream DontUpdateFlg) (* fgh: "16-Oct-85 16:30") (* * rht 1/9/85: Keep track of the total number of cards in NC.UncachingNotCompleted.) (* * rht 1/31/85: Increases array size if needed. Also now stores highest ID number in a global var and only writes to the file at checkpoint time.) (* * rht 2/1/85: Now warn user if within 90% of index full. Also if index array is full, then increase its size.) (* * fgh 10/15/85 increase cache arry size when necessary) (WITH.MONITOR (NC.FetchMonitor DatabaseStream) (PROG (NextIDNum PercentUsed (Stream (COND ((STREAMP DatabaseStream) DatabaseStream) ((AND DatabaseStream (OPENP DatabaseStream (QUOTE BOTH))) (GETSTREAM DatabaseStream)) (T (NC.ReportError "NC.GetNewID" (CONCAT DatabaseStream " not a stream or file."))))) ) (SETQ NextIDNum (STREAMPROP Stream (QUOTE NCNEXTIDNUM))) (COND ((IGREATERP (SETQ PercentUsed (FIX (TIMES 100 (QUOTIENT (FLOAT NextIDNum) (FLOAT NC.IndexSizeInEntries))))) 90) (NC.PrintMsg NIL T "Index for notefile: " (FULLNAME Stream) " is " PercentUsed "%% full." (CHARACTER 13) "Please close notefile soon and compact."))) (COND ((EQ NextIDNum NC.IndexSizeInEntries) (NC.ReportError "NC.GetNewID" "Index full."))) (SETQ NC.UncachingNotCompleted NextIDNum) (COND ((IGREATERP (ITIMES 5 NextIDNum) (ARRAYSIZE (STREAMPROP Stream (QUOTE NCINDEXARRAY)))) (NC.IncreaseIndexArray Stream))) (COND ((IGREATERP NextIDNum (ARRAYSIZE (STREAMPROP Stream (QUOTE NCCACHEARRAY)))) (NC.IncreaseCacheArray Stream))) (RETURN (PROG1 (NC.IDFromNumber NextIDNum) (OR DontUpdateFlg (STREAMPROP Stream (QUOTE NCNEXTIDNUM) (ADD1 NextIDNum))))))))) (NC.CloseDatabaseFile (LAMBDA NIL (* fgh: "16-Oct-85 15:33") (* 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.) (* * rht 7/14/85: Replaced the call to reset the main menu with call to NC.ResetMainMenu. Also took out redundant reset of PSA.Database, since NC.ForceDatabaseClose is doing that.) (* * fgh 10/16/85 removed call to CacheTypesAndTitles because uncacheing now done automatically by cache mechanism.) (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) NIL NIL NIL NIL T)) (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)) (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) (NC.ResetMainMenu) (NC.PrintMsg NIL T File " closed.")))))) (NC.OpenDatabaseFile (LAMBDA (FileName Access NoSetFlg QuietFlg Don'tCreateFlg Convertw/oConfirmFlg Don'tCreateArrayFlg Don'tTruncateFlg) (* fgh: "16-Oct-85 17:39") (* Open an already existing database file.) (* * 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.) (PROG (Name Stream NewStream ID CardTotal) (OR Access (SETQ Access (QUOTE BOTH))) (COND ((AND PSA.Database (OPENP PSA.Database)) (NC.PrintMsg NIL T "There is already an open NoteFile -- " (FULLNAME PSA.Database) (CHARACTER 13) "It must be closed before a new one" " can be opened." (CHARACTER 13)) (RETURN NIL))) (AND (NULL FileName) (NULL (SETQ FileName (NC.DatabaseFileName "Name of NoteFile to open:" " -- " T))) (RETURN NIL)) (COND ((OPENP FileName) (NC.PrintMsg NIL T FileName " is an already open file." (CHARACTER 13)) (RETURN))) (AND (NOT (SETQ Name (INFILEP FileName))) (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)) (NC.CreateDatabaseFile FileName NIL "Opening NoteFile" T) (AND (NOT (SETQ Name (INFILEP FileName))) (NC.PrintMsg NIL T "Still unable to find Notefile " FileName "." (CHARACTER 13)) (RETURN NIL))) (T (RETURN NIL)))) (AND (NULL QuietFlg) (NC.PrintMsg NIL T "Opening ... " (CHARACTER 13))) (SETQ Stream (OPENSTREAM Name Access (QUOTE OLD))) (NC.SetMonitor Stream (CREATE.MONITORLOCK (MKATOM (CONCAT Name ":LOCK")))) (SETFILEPTR Stream 0) (STREAMPROP Stream (QUOTE NCNEXTIDNUM) (NC.GetPtr Stream 2)) (COND ((NULL (SETQ NewStream (NC.CheckForNeededConversion Stream Access Convertw/oConfirmFlg))) (CLOSEF Stream) (RETURN NIL)) (T (NC.SetMonitor NewStream (NC.FetchMonitor Stream)) (SETQ Stream NewStream))) (COND ((AND (NULL Don'tTruncateFlg) (SETQ NewStream (NC.CheckForNeededTruncation Stream Access))) (* Can either bail out entirely or run inspector and then bail out.) (SELECTQ NewStream (ABORT (CLOSEF Stream) (RETURN NIL)) (ABORTANDINSPECT (CLOSEF Stream) (NC.ScavengerPhase1 Name) (RETURN NIL)) NIL))) (COND (NewStream (NC.SetMonitor NewStream (NC.FetchMonitor Stream)) (SETQ Stream NewStream))) (SETFILEPTR Stream 0) (STREAMPROP Stream (QUOTE NCNEXTIDNUM) (NC.GetPtr Stream 2)) (SETTOPVAL (QUOTE NC.IndexSizeInEntries) (NC.GetPtr Stream 2)) (STREAMPROP Stream (QUOTE NCNEXTLINKID) (NC.GetPtr Stream)) (OR Don'tCreateArrayFlg (NC.BuildIndexArray Stream)) (OR Don'tCreateArrayFlg (NC.BuildCacheArray Stream)) (COND ((NULL NoSetFlg) (SETQ PSA.Database Stream) (* Cache all of the titles in this database) (NC.CacheTypesAndTitles PSA.Database NIL QuietFlg "Opening NoteFile.") (NC.SetMainMenuTitle Stream))) (AND (NULL QuietFlg) (NC.PrintMsg NIL T "Opened " (FULLNAME Stream) (CHARACTER 13))) (RETURN Stream)))) (NC.InitializeSpecialCards (LAMBDA (DatabaseStream) (* fgh: "16-Oct-85 01:02") (* Create and put the initial versions of Root, Orphan, and Unclassified cards onto database specified by DatabaseStream. Also initialize the List of link labels) (RESETVAR PSA.Database DatabaseStream (PROG ((Root NC.RootID) (Orphan NC.OrphanID) (Unclassified NC.UnclassifiedID) (LinkLabels NC.LinkLabelsID)) (* Root card) (NC.MakeNoteCard (QUOTE FileBox) "Table of Contents" T NIL Root DatabaseStream) (NC.SetPropList Root NIL DatabaseStream) (NC.PutNoteCard Root DatabaseStream) (NC.PutTitle Root DatabaseStream) (NC.PutPropList Root DatabaseStream) (NC.PutLinks Root DatabaseStream) (NC.DeactivateCard Root T DatabaseStream) (* Orphan card) (NC.MakeNoteCard (QUOTE FileBox) "Orphans" T NIL Orphan DatabaseStream) (NC.SetPropList Orphan NIL DatabaseStream) (NC.PutNoteCard Orphan DatabaseStream) (NC.PutTitle Orphan DatabaseStream) (NC.PutPropList Orphan DatabaseStream) (NC.PutLinks Orphan DatabaseStream) (NC.DeactivateCard Orphan T DatabaseStream) (* Unclassified Card) (NC.MakeNoteCard (QUOTE FileBox) "To Be Filed" T NIL Unclassified DatabaseStream) (NC.SetPropList Unclassified NIL DatabaseStream) (NC.PutNoteCard Unclassified DatabaseStream) (NC.PutTitle Unclassified DatabaseStream) (NC.PutPropList Unclassified DatabaseStream) (NC.PutLinks Unclassified DatabaseStream) (NC.DeactivateCard Unclassified T DatabaseStream) (* Link Labels) (NC.PutLinkLabels DatabaseStream NC.InitialLinkLabels) (RETURN DatabaseStream))))) (NC.SaveDirtyCards (LAMBDA (Stream) (* fgh: "16-Oct-85 16:45") (* * Save every card that is both active and dirty to the notefile.) (* * rht 9/21/85: Now records cards that were shrunken and reshrinks after checkpoint is completed.) (* * fgh 10/15/85 Put in stuff to make using cache array efficient) (PROG (ShrunkenCardWins ActiveCards CacheArray) (SETQ CacheArray (NC.FetchCacheArray Stream)) (SETQ ActiveCards (for CardNumber from 1 to (SUB1 (SUBATOM (NC.GetNewID Stream T) 3)) when (NC.ActiveCardP CardNumber Stream CacheArray) eachtime (BLOCK) collect (NC.IDFromNumber CardNumber))) (SETQ ShrunkenCardWins (for Win in (OPENWINDOWS) bind UnshrunkenWin eachtime (BLOCK) when (FMEMB (NC.IDFromWindow (SETQ UnshrunkenWin (WINDOWPROP Win (QUOTE ICONFOR)))) ActiveCards) collect UnshrunkenWin)) (RESETLST (RESETSAVE NC.ForceSourcesFlg NIL) (RESETSAVE NC.ForceTitlesFlg NIL) (for Card in ActiveCards eachtime (BLOCK) do (NC.CardSaveFn Card Stream))) (for Win in ShrunkenCardWins eachtime (BLOCK) do (SHRINKW Win))))) ) (PUTPROPS FGHCACHE COPYRIGHT ("Xerox Corporation" 1985)) (DECLARE: DONTCOPY (FILEMAP (NIL (4080 8685 (NC.FetchCardCache 4090 . 4554) (NC.FetchCacheArray 4556 . 5385) ( NC.InsureIntegerDate 5387 . 5741) (NC.SetCacheUserProp 5743 . 6380) (NC.FetchCacheUserProp 6382 . 6908 ) (NC.BuildCacheArray 6910 . 7458) (NC.IncreaseCacheArray 7460 . 8357) (NC.SetCardCache 8359 . 8683)) (8721 17374 (NC.SetNewCardFlg 8731 . 9119) (NC.ActivateCard 9121 . 9472) (NC.SetFromLinks 9474 . 9805) (NC.SetGlobalLinks 9807 . 10151) (NC.SetLinksDirtyFlg 10153 . 10530) (NC.SetPropList 10532 . 10861) ( NC.SetRegion 10863 . 11181) (NC.SetSavedRegion 11183 . 11527) (NC.SetRegionViewed 11529 . 11841) ( NC.SetScale 11843 . 12125) (NC.SetTitle 12127 . 12446) (NC.SetToLinks 12448 . 12776) (NC.SetType 12778 . 13101) (NC.SetTitleDirtyFlg 13103 . 13465) (NC.SetPropListDirtyFlg 13467 . 13835) ( NC.SetSubstanceDirtyFlg 13837 . 14207) (NC.SetBeingDeletedFlg 14209 . 14581) (NC.SetTitleDate 14583 . 14965) (NC.SetItemDate 14967 . 15340) (NC.SetPropListDate 15342 . 15732) (NC.SetLinksDate 15734 . 16116) (NC.SetSubstance 16118 . 16477) (NC.DeactivateCard 16479 . 17372)) (17375 25338 ( NC.FetchNewCardFlg 17385 . 17756) (NC.ActiveCardP 17758 . 18215) (NC.FetchFromLinks 18217 . 18528) ( NC.FetchGlobalLinks 18530 . 18853) (NC.FetchLinksDirtyFlg 18855 . 19187) (NC.FetchPropList 19189 . 19501) (NC.FetchRegion 19503 . 19812) (NC.FetchSavedRegion 19814 . 20137) (NC.FetchRegionViewed 20139 . 20454) (NC.FetchScale 20456 . 20757) (NC.FetchTitle 20759 . 21064) (NC.FetchToLinks 21066 . 21373) (NC.FetchType 21375 . 21686) (NC.FetchTitleDirtyFlg 21688 . 22013) (NC.FetchPropListDirtyFlg 22015 . 22370) (NC.FetchSubstanceDirtyFlg 22372 . 22723) (NC.FetchBeingDeletedFlg 22725 . 23079) ( NC.FetchTitleDate 23081 . 23565) (NC.FetchItemDate 23567 . 24048) (NC.FetchPropListDate 24050 . 24537) (NC.FetchLinksDate 24539 . 25023) (NC.FetchSubstance 25025 . 25336)) (25339 28493 (NC.MakeNoteCard 25349 . 28491)) (28532 41873 (NC.GetNewID 28542 . 30755) (NC.CloseDatabaseFile 30757 . 33670) ( NC.OpenDatabaseFile 33672 . 38109) (NC.InitializeSpecialCards 38111 . 40440) (NC.SaveDirtyCards 40442 . 41871))))) STOP