(FILECREATED "26-Feb-86 16:07:05" {QV}<NOTECARDS>1.3K>RHTPATCH031.;3 7222   

      changes to:  (VARS RHTPATCH031COMS)
		   (FNS NC.GetSpecialCards)

      previous date: "26-Feb-86 12:04:29" {QV}<NOTECARDS>1.3K>RHTPATCH031.;1)


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

(PRETTYCOMPRINT RHTPATCH031COMS)

(RPAQQ RHTPATCH031COMS ((* * Fixes to NCDATABASE to handle new Registry special card.)
			  (* * NOTE: NOTECARDS COMS must be changed to load NCHASHCARD at the same 
			     time that these patches are integrated.)
			  (RECORDS NoteFile)
			  (FNS NC.InitializeSpecialCards NC.GetSpecialCards NC.GetHashArray)))
(* * Fixes to NCDATABASE to handle new Registry special card.)

(* * NOTE: NOTECARDS COMS must be changed to load NCHASHCARD at the same time that these 
patches are integrated.)

[DECLARE: EVAL@COMPILE 

(DATATYPE NoteFile (UID Stream FullFileName HashArray (HashArraySize FIXP)
			  (NextIndexNum FIXP)
			  (Version BYTE)
			  (NextLinkNum FIXP)
			  (CheckptPtr FIXP)
			  LinkLabelsCard TableOfContentsCard ToBeFiledCard OrphansCard RegistryCard 
			  ReservedCards Menu MonitorLock ExclusiveAccessMonitor CachingProcess 
			  IndexNumsFreeList UserProps))
]
(/DECLAREDATATYPE (QUOTE NoteFile)
		  (QUOTE (POINTER POINTER POINTER POINTER FIXP FIXP BYTE FIXP FIXP POINTER POINTER 
				  POINTER POINTER POINTER POINTER POINTER POINTER POINTER POINTER 
				  POINTER POINTER))
		  (QUOTE ((NoteFile 0 POINTER)
			  (NoteFile 2 POINTER)
			  (NoteFile 4 POINTER)
			  (NoteFile 6 POINTER)
			  (NoteFile 8 FIXP)
			  (NoteFile 10 FIXP)
			  (NoteFile 6 (BITS . 7))
			  (NoteFile 12 FIXP)
			  (NoteFile 14 FIXP)
			  (NoteFile 16 POINTER)
			  (NoteFile 18 POINTER)
			  (NoteFile 20 POINTER)
			  (NoteFile 22 POINTER)
			  (NoteFile 24 POINTER)
			  (NoteFile 26 POINTER)
			  (NoteFile 28 POINTER)
			  (NoteFile 30 POINTER)
			  (NoteFile 32 POINTER)
			  (NoteFile 34 POINTER)
			  (NoteFile 36 POINTER)
			  (NoteFile 38 POINTER)))
		  (QUOTE 40))
(DEFINEQ

(NC.InitializeSpecialCards
  (LAMBDA (NoteFile)                                         (* rht: "26-Feb-86 11:45")

          (* Create and put the initial versions of Root, Orphan, and Unclassified cards onto database specified by 
	  DatabaseStream. Also initialize the List of link labels)



          (* * rht 11/10/85: Updated to handle new NoteFile and Card scheme.)



          (* * rht 11/14/85: Now sticks top level cards into NoteFile object.)



          (* * rht 2/26/86: Added new special card, the RegistryCard.)

                                                             (* Contents card)
    (replace (NoteFile TableOfContentsCard) of NoteFile with (NC.InitializeSpecialCard
								     (QUOTE FileBox)
								     NoteFile "Table of Contents"))
                                                             (* Orphans card)
    (replace (NoteFile OrphansCard) of NoteFile with (NC.InitializeSpecialCard (QUOTE
											 FileBox)
										       NoteFile 
										       "Orphans"))
                                                             (* ToBeFiled Card)
    (replace (NoteFile ToBeFiledCard) of NoteFile with (NC.InitializeSpecialCard
							       (QUOTE FileBox)
							       NoteFile "To Be Filed"))
                                                             (* Link Labels)
    (replace (NoteFile LinkLabelsCard) of NoteFile with (NC.InitializeSpecialCard
								(QUOTE List)
								NoteFile "Link Labels" 
								NC.InitialLinkLabels))
    (replace (NoteFile RegistryCard) of NoteFile with (NC.InitializeSpecialCard (QUOTE
											  Registry)
											NoteFile 
										       "Registry"))
    NoteFile))

(NC.GetSpecialCards
  (LAMBDA (NoteFile)                                         (* rht: "26-Feb-86 11:49")

          (* * 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)
				 (fetch (NoteFile RegistryCard) of NoteFile)))))

(NC.GetHashArray
  (LAMBDA (NoteFile QuietFlg OperationMsg Don'tGetSpecialCardsFlg)
                                                             (* rht: "26-Feb-86 14:21")

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



          (* * rht 2/26/86: Added extra special Registry card.)


    (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 6)
				      (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))
						 (5 (replace (NoteFile RegistryCard) of NoteFile
						       with Card))
						 NIL)))
		       (replace (NoteFile IndexNumsFreeList) of NoteFile with IndexNumsFreeList)
		    ))))
)
(PUTPROPS RHTPATCH031 COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (2026 7140 (NC.InitializeSpecialCards 2036 . 3839) (NC.GetSpecialCards 3841 . 4413) (
NC.GetHashArray 4415 . 7138)))))
STOP