(FILECREATED " 1-Nov-86 18:34:39" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH130.;10 43049  

      changes to:  (VARS RHTPATCH130COMS)
		   (FNS NC.FixUpLinksInCardCopy NC.DisassembleUID NC.CopyNoteFile NC.RenameNoteFile 
			NC.RegistryCardPutFn NC.RegistryCardGetFn NC.ListCardPutFn NC.ListCardGetFn 
			NC.CrossFileLinkPutFn NC.CrossFileLinkGetFn NC.PutSketchSubstance 
			NC.PutCachedMap NC.GetSketchSubstance NC.GetCachedMap NC.RobustRead 
			NC.WriteBrowserLinkLabels NC.WriteBrowserFormat NC.WriteSpecialBrowserSpecs 
			NC.WriteBrowserDepth NC.WriteBrowserLinksLegend 
			NC.WriteBrowserSavedLinkingInfo NC.WriteBrowserSavedLinkingInfoForNode 
			NC.ReadBrowserRootsInfo NC.ReadBrowserLinkLabels NC.ReadBrowserFormat 
			NC.ReadSpecialBrowserSpecs NC.ReadBrowserDepth NC.ReadBrowserLinksLegend 
			NC.ReadBrowserSavedLinkingInfo NC.ReadBrowserSavedLinkingInfoForNode 
			NC.BuildVerticalBarREADTABLE NC.WriteIdentifier NC.WriteListOfLinks 
			NC.WriteDate NC.WriteCardType NC.WriteTitle NC.WritePropList NC.WriteLink 
			NC.ReadListOfLinks NC.ReadIdentifier NC.ReadDate NC.ReadCardType NC.ReadTitle 
			NC.ReadPropList NC.ReadLink)

      previous date: " 1-Nov-86 14:57:51" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH130.;1)


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

(PRETTYCOMPRINT RHTPATCH130COMS)

(RPAQQ RHTPATCH130COMS ((* * Fixes to printing and reading to make running NoteCards in Lyric 
			     possible.)
			  (* * Changes to NCDATABASE)
			  (FNS NC.BuildVerticalBarREADTABLE NC.DisassembleUID)
			  (FNS NC.WriteIdentifier NC.WriteListOfLinks NC.WriteDate NC.WriteCardType 
			       NC.WriteTitle NC.WritePropList NC.WriteLink)
			  (FNS NC.ReadListOfLinks NC.ReadIdentifier NC.ReadDate NC.ReadCardType 
			       NC.ReadTitle NC.ReadPropList NC.ReadLink)
			  (FNS NC.FixUpLinksInCardCopy NC.CopyNoteFile NC.RenameNoteFile)
			  (* * Changes to NCREPAIR)
			  (FNS NC.RobustRead)
			  (* * Changes to NCBROWSERCARD)
			  (FNS NC.WriteBrowserLinkLabels NC.WriteBrowserFormat 
			       NC.WriteSpecialBrowserSpecs NC.WriteBrowserDepth 
			       NC.WriteBrowserLinksLegend NC.WriteBrowserSavedLinkingInfoForNode)
			  (FNS NC.ReadBrowserLinkLabels NC.ReadBrowserFormat 
			       NC.ReadSpecialBrowserSpecs NC.ReadBrowserDepth 
			       NC.ReadBrowserLinksLegend NC.ReadBrowserSavedLinkingInfoForNode)
			  (* * Changes to NCSKETCHCARD)
			  (FNS NC.PutSketchSubstance NC.PutCachedMap)
			  (FNS NC.GetSketchSubstance NC.GetCachedMap)
			  (* * Changes to NCLISTCARD)
			  (FNS NC.ListCardPutFn)
			  (FNS NC.ListCardGetFn)
			  (* * Changes to NCREGISTRYCARD)
			  (FNS NC.RegistryCardPutFn)
			  (FNS NC.RegistryCardGetFn)
			  (* * Changes to NCCROSSFILELINKS)
			  (FNS NC.CrossFileLinkPutFn)
			  (FNS NC.CrossFileLinkGetFn)))
(* * Fixes to printing and reading to make running NoteCards in Lyric possible.)

(* * Changes to NCDATABASE)

(DEFINEQ

(NC.BuildVerticalBarREADTABLE
  (LAMBDA NIL                                                (* rht: " 1-Nov-86 14:52")

          (* * Return a new readtable formed from the primary readtable by changing verticalbar's syntax class to be that of 
	  terminal readtable.)



          (* * rht 11/1/86: Now makes copy of ORIG readtable rather than "NIL" one.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (LET ((NewReadTable (COPYREADTABLE NC.OrigReadTable)))
         (SETSYNTAX 124 (GETSYNTAX 124 T)
		      NewReadTable)
     NewReadTable)))

(NC.DisassembleUID
  (LAMBDA (UID Stream)                                       (* rht: " 1-Nov-86 17:34")

          (* * This is called when PRINT, PRIN1, etc. try to print instance of UID datatype. Returns cons of readmacro 
	  character and list to be written down which when eval'ed at read time will reassemble the UID.)



          (* * rht 1/31/86: Now checks Stream arg and only disassembles if going to a notecards stream.)



          (* * rht 2/1/86: It's too slow to check whether Stream is for a notefile. Now just check whether there's a non-nil 
	  and non-T Stream.)



          (* * rht 2/4/86: Also be sure Stream is not a window stream.)



          (* * rht 11/1/86: Changed a little weirdness in the readmacro atom so compiled version of this fn can be read in 
	  lyric.)


    (if (AND Stream (NEQ Stream (QUOTE T))
		 (NOT (IMAGESTREAMP Stream)))
	then (CONS (MKATOM "|.")
		       (LIST (FUNCTION NC.ReassembleUID)
			       (ffetch (UID UID0) of UID)
			       (ffetch (UID UID1) of UID)
			       (ffetch (UID UID2) of UID)
			       (ffetch (UID UID3) of UID)
			       (ffetch (UID UID4) of UID)
			       (ffetch (UID UID5) of UID)
			       (ffetch (UID UID6) of UID)))
      else NIL)))
)
(DEFINEQ

(NC.WriteIdentifier
  (LAMBDA (NoteFileOrStream Identifier)                      (* rht: " 1-Nov-86 15:05")
                                                             (* Put Identifier on DatabaseStream)

          (* * Now puts out new data format style. This consists of the identifier with the last two #'s clipped off followed
	  by the data format version byte.)



          (* * rht 11/12/85: Now handles new notefile format.)



          (* * rht 11/24/85: Assumes identifier is already clipped.)



          (* * rht 1/23/86: Now takes notefile or stream as arg.)


    (DECLARE (GLOBALVARS NC.DataFormatVersionNumber NC.OrigReadTable))
    (LET ((Stream (NC.CoerceToNoteFileStream NoteFileOrStream)))
         (PRINT Identifier Stream NC.OrigReadTable)
         (NC.WritePtr Stream NC.DataFormatVersionNumber 1))))

(NC.WriteListOfLinks
  (LAMBDA (NoteFileOrStream Links)                           (* rht: " 1-Nov-86 15:09")

          (* * Write the given links down to the notefile, coercing NoteFile object to NF-UID if necessary.)



          (* * rht 1/23/86: Now takes notefile or stream as arg.)



          (* * rht 11/1/86: Now uses our readtable when printing.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (LET ((Stream (NC.CoerceToNoteFileStream NoteFileOrStream)))
         (for Link in Links when (type? Link Link) do (NC.WriteLink Link Stream))
         (NC.WritePtr Stream 0 1)
         (PRINT (QUOTE EndLinks)
		  Stream NC.OrigReadTable))))

(NC.WriteDate
  (LAMBDA (NoteFileOrStream Date)                            (* rht: " 1-Nov-86 15:05")

          (* * Write a date string out to Stream.)



          (* * rht 11/12/85: Handles new notefile format.)



          (* * rht 1/23/86: Now takes notefile or stream as arg.)



          (* * rht 11/1/86: Now uses our readtable when printing.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (PRINT Date (NC.CoerceToNoteFileStream NoteFileOrStream)
	     NC.OrigReadTable)))

(NC.WriteCardType
  (LAMBDA (NoteFileOrStream CardType)                        (* rht: " 1-Nov-86 15:05")

          (* * Writes a card type down to notefile.)



          (* * rht 1/23/86: Now takes notefile or stream as arg.)



          (* * rht 11/1/86: Now uses our readtable when printing.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (PRINT CardType (NC.CoerceToNoteFileStream NoteFileOrStream)
	     NC.OrigReadTable)))

(NC.WriteTitle
  (LAMBDA (NoteFileOrStream Title)                           (* rht: " 1-Nov-86 15:06")

          (* * Write a title out to Stream.)



          (* * rht 1/23/86: Now takes notefile or stream as arg.)



          (* * rht 11/1/86: Now uses our readtable when printing.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (PRINT Title (NC.CoerceToNoteFileStream NoteFileOrStream)
	     NC.OrigReadTable)))

(NC.WritePropList
  (LAMBDA (NoteFileOrStream PropList)                        (* rht: " 1-Nov-86 15:06")

          (* * Write a prop list out to Stream.)



          (* * rht 1/23/86: Now takes notefile or stream as arg.)



          (* * rht 11/1/86: Now uses our readtable when printing.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (PRINT PropList (NC.CoerceToNoteFileStream NoteFileOrStream)
	     NC.OrigReadTable)))

(NC.WriteLink
  (LAMBDA (Link Stream)                                      (* rht: " 1-Nov-86 15:06")

          (* * Write a single link DATAYPE instance down to Stream)



          (* * rht 11/1/86: Now uses our readtable when printing.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (LET ((SourceCard (fetch (Link SourceCard) of Link))
	  (DestinationCard (fetch (Link DestinationCard) of Link)))

          (* * This is version 1 link format)


         (NC.WritePtr Stream 1 1)
         (NC.WriteUID Stream (fetch (Link UID) of Link))
         (NC.WriteUID Stream (fetch (Card UID) of SourceCard))
         (NC.WriteUID Stream (fetch (NoteFile UID) of (fetch (Card NoteFile) of SourceCard))
			)
         (NC.WriteUID Stream (fetch (Card UID) of DestinationCard))
         (NC.WriteUID Stream (fetch (NoteFile UID) of (fetch (Card NoteFile) of 
										  DestinationCard)))
         (PRINT (fetch (Link AnchorMode) of Link)
		  Stream NC.OrigReadTable)
         (PRINT (fetch (Link Label) of Link)
		  Stream NC.OrigReadTable)
         (PRINT (fetch (Link DisplayMode) of Link)
		  Stream NC.OrigReadTable))))
)
(DEFINEQ

(NC.ReadListOfLinks
  (LAMBDA (NoteFileOrStream)                                 (* rht: " 1-Nov-86 15:09")

          (* * Read a list of link records from the notefile. Create a datatype instance for each.)



          (* * rht 11/14/85: Now uses NC.CardFromUID to get Card object from hash array.)



          (* * rht 1/23/86: Now takes notefile or stream as arg.)



          (* * rht 11/1/86: Now uses our readtable when reading.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (LET ((Stream (NC.CoerceToNoteFileStream NoteFileOrStream)))
         (PROG1 (bind Link while (SETQ Link (NC.ReadLink Stream)) collect Link)

          (* * Read past the end of list identifier)


		  (READ Stream NC.OrigReadTable)
		  (BIN Stream)))))

(NC.ReadIdentifier
  (LAMBDA (NoteFileOrStream Identifier)                      (* rht: " 1-Nov-86 15:10")
                                                             (* Return T if next item on databaseStream is the 
							     identifier specified by Identifier)

          (* * rht 2/4/85: A horrible hack for the case of titles identifier. This is because a previous typo was causing 
	  NOBIND to get written for titles identifiers.)



          (* * rht 7/9/85: Now checks for new data format. This is indicated by identifiers with the last two #'s clipped 
	  off. Then comes the one-byte version number of the data format. If identifier is not clipped then it's old style 
	  and there is no version number. Return version number if there is one, 0 if old style, and NIL if can't match 
	  identifier.)



          (* * fkr 11/8/85 Changed to handle NoteFile object.)



          (* * rht 11/24/85: No longer worries about the screwy NOBIND Titles identifier. Also assumes Identifier is already 
	  clipped.)



          (* * rht 1/23/86: Now takes notefile or stream as arg.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (LET ((Stream (NC.CoerceToNoteFileStream NoteFileOrStream)))
         (if (AND (EQ (READ Stream NC.OrigReadTable)
			    Identifier)
		      (NUMBERP (PROGN                    (* First char is separator.
							     Next is one-byte version number.)
					  (BIN Stream)
					  (NC.ReadPtr Stream 1))))
	   else NIL))))

(NC.ReadDate
  (LAMBDA (NoteFileOrStream)                                 (* rht: " 1-Nov-86 15:11")

          (* * Read a date string from Stream. All dates have the same length, so can use that as a check.
	  I'm allowing null date since we may be compacting an old style (non-dated) notefile. Thus we won't give it a 
	  misleadingly new date.)



          (* * rht 11/11/85: Now handles new notefile object.)



          (* * rht 1/23/86: Now takes notefile or stream as arg.)



          (* * rht 11/1/86: Now uses our readtable when reading.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (LET ((Stream (NC.CoerceToNoteFileStream NoteFileOrStream))
	  Date)

          (* * Read Date)


         (SETQ Date (READ Stream NC.OrigReadTable))

          (* * Read past CR)


         (BIN Stream)
         (COND
	   ((OR (NULL Date)
		  (EQ (NCHARS Date)
			NC.DateStringLength))
	     Date)
	   (T (NC.ReportError "NC.GetDate" (CONCAT Date " is not a proper date."))
	      NIL)))))

(NC.ReadCardType
  (LAMBDA (NoteFileOrStream)                                 (* rht: " 1-Nov-86 15:11")

          (* * Get a card type off of the file.)



          (* * rht 1/23/86: Now takes notefile or stream as arg.)



          (* * rht 11/1/86: Now uses our readtable when reading.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (LET ((Stream (NC.CoerceToNoteFileStream NoteFileOrStream)))
         (PROG1 (READ Stream NC.OrigReadTable)

          (* * read past CR)


		  (BIN Stream)))))

(NC.ReadTitle
  (LAMBDA (NoteFileOrStream)                                 (* rht: " 1-Nov-86 15:11")

          (* * Get a title off of the file.)



          (* * rht 1/23/86: Now takes notefile or stream as arg.)



          (* * rht 11/1/86: Now uses our readtable when reading.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (READ (NC.CoerceToNoteFileStream NoteFileOrStream)
	    NC.OrigReadTable)))

(NC.ReadPropList
  (LAMBDA (NoteFileOrStream)                                 (* rht: " 1-Nov-86 15:12")

          (* * Get a prop list off of the file.)



          (* * rht 1/23/86: Now takes notefile or stream as arg.)



          (* * rht 11/1/86: Now uses our readtable when reading.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (READ (NC.CoerceToNoteFileStream NoteFileOrStream)
	    NC.OrigReadTable)))

(NC.ReadLink
  (LAMBDA (Stream)                                           (* rht: " 1-Nov-86 15:13")

          (* * Read a single Link DATAYPE instance from Stream)



          (* * Link identifier and CR)



          (* * rht 11/25/85: Now handles case of version 2 style link.)



          (* * fgh 8/27/86 Put in Kludge to handle problem with some versions of WRITE.IMAGEOBJ that put in an extra CR 
	  before the stuff.)



          (* * rht 11/1/86: Now uses our readtable when reading.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (LET ((FirstChar (NC.ReadPtr Stream 1)))
         (COND
	   ((ZEROP FirstChar)

          (* * Version Number 0 means end of list of links)


	     NIL)
	   ((EQ FirstChar 1)

          (* * The link info for a version 3 style link.)


	     (PROG1 (create Link
				UID ←(NC.ReadUID Stream)
				SourceCard ←(NC.CardOrCardHolderFromUID (NC.ReadUID Stream)
									  (NC.ReadUID Stream))
				DestinationCard ←(NC.CardOrCardHolderFromUID (NC.ReadUID Stream)
									       (NC.ReadUID Stream))
				AnchorMode ←(READ Stream NC.OrigReadTable)
				Label ←(READ Stream NC.OrigReadTable)
				DisplayMode ←(READ Stream NC.OrigReadTable))

          (* * Get that damn CR)


		      (BIN Stream)))
	   ((EQ FirstChar 13)

          (* * KLUDGE to account for fact that some versions of WRITE.IMAGEOBJ put a CR before beginning the actual stuff.)


	     (NC.ReadLink Stream))
	   (T 

          (* * Version 2 style link. Move back over the left parantheses and read the link as a list.)


	      (SETFILEPTR Stream (SUB1 (GETFILEPTR Stream)))
	      (READ Stream NC.OrigReadTable))))))
)
(DEFINEQ

(NC.FixUpLinksInCardCopy
  (LAMBDA (CardCopy CardHashArray LinksHashArray CurrentLinkLabels NewLinkLabels)
                                                             (* rht: " 1-Nov-86 18:24")

          (* * For all the links from or to CardCopy, change other endpoint's card according to mapping table in 
	  CardHashArray. If other endpoint is a card not found in the hash array, then drop that link altogether.
	  The mapping from old link UIDs to new ones is in LinksHashArray. Any new link labels not in CurrentLinkLabels get 
	  TCONC'ed onto NewLinkLabels.)



          (* * rht 2/17/86: Now uses NC.ApplyFn instead of APPLY* for deleting and collecting references.)



          (* * rht 11/1/86: Added missing var bindings and a (BLOCK))


    (LET ((CardCopyType (NC.FetchType CardCopy)))

          (* * Fix all the From links.)


         (NC.SetFromLinks CardCopy (for Link in (NC.FetchFromLinks CardCopy) eachtime
										      (BLOCK)
					bind SourceCard OldLinkUID LinkLabel
					when (SETQ SourceCard (GETHASH (fetch (Link 
										       SourceCard)
										of Link)
									     CardHashArray))
					collect (replace (Link DestinationCard) of Link
						     with CardCopy)
						  (replace (Link SourceCard) of Link
						     with SourceCard)
						  (replace (Link UID) of Link
						     with (OR (GETHASH (SETQ OldLinkUID
									       (fetch (Link UID)
										  of Link))
									     LinksHashArray)
								  (PUTHASH OldLinkUID (NC.MakeUID)
									     LinksHashArray)))
                                                             (* Keep track of link labels in case any are new.)
						  (OR (FMEMB (SETQ LinkLabel
								   (fetch (Link Label)
								      of Link))
								 CurrentLinkLabels)
							(NC.SystemLinkLabelP LinkLabel)
							(FMEMB LinkLabel (CAR NewLinkLabels))
							(TCONC NewLinkLabels LinkLabel))
						  Link))

          (* * Do it all again for the To links.)


         (NC.SetToLinks CardCopy (for Link in (NC.FetchToLinks CardCopy) eachtime (BLOCK)
				      bind DestCard OldLinkUID LinkLabel
				      when (SETQ DestCard (GETHASH (fetch (Link 
										  DestinationCard)
									    of Link)
									 CardHashArray))
				      collect (replace (Link SourceCard) of Link with 
											 CardCopy)
						(replace (Link DestinationCard) of Link
						   with DestCard)
						(replace (Link UID) of Link
						   with (OR (GETHASH (SETQ OldLinkUID
									     (fetch (Link UID)
										of Link))
									   LinksHashArray)
								(PUTHASH OldLinkUID (NC.MakeUID)
									   LinksHashArray)))
                                                             (* Keep track of link labels in case any are new.)
						(OR (FMEMB (SETQ LinkLabel (fetch
								   (Link Label) of Link))
							       CurrentLinkLabels)
						      (NC.SystemLinkLabelP LinkLabel)
						      (FMEMB LinkLabel (CAR NewLinkLabels))
						      (TCONC NewLinkLabels LinkLabel))
						Link))

          (* * Now fix the links inside imageobj's in the card's substance.)


         (AND (fetch (Card LinkAnchorModesSupported) of CardCopy)
		(for Link in (CAR (NC.ApplyFn CollectLinksFn CardCopy)) eachtime (BLOCK)
		   bind OldLinkUID DestCard LinkLabel
		   do (if (SETQ DestCard (GETHASH (fetch (Link DestinationCard)
							     of Link)
							  CardHashArray))
			    then (replace (Link SourceCard) of Link with CardCopy)
				   (replace (Link DestinationCard) of Link with DestCard)
				   (replace (Link UID) of Link
				      with (OR (GETHASH (SETQ OldLinkUID (fetch
								  (Link UID) of Link))
							      LinksHashArray)
						   (PUTHASH OldLinkUID (NC.MakeUID)
							      LinksHashArray)))
                                                             (* Keep track of link labels in case any are new.)
				   (OR (FMEMB (SETQ LinkLabel (fetch (Link Label)
								       of Link))
						  CurrentLinkLabels)
					 (NC.SystemLinkLabelP LinkLabel)
					 (FMEMB LinkLabel (CAR NewLinkLabels))
					 (TCONC NewLinkLabels LinkLabel))
			  else (NC.ApplyFn DeleteLinksFn CardCopy Link)))))))

(NC.CopyNoteFile
  (LAMBDA (FromNoteFileOrName ToFileName Window)             (* rht: " 1-Nov-86 18:21")

          (* * Copy a notefile. Ask user for names of FromNoteFileOrName and ToFileName.)



          (* * fkr 11/8/85: Ripped out PSA.Database check. Now takes FromNoteFileOrName and ToFileName args.)



          (* * kirk 19May86 Fixed to work from NoteFile menu)



          (* * fgh 6/24/86 Fixed bug where would not work if NULL FromNoteFileOrName)



          (* * fgh 7/5/86 Closes prompt window when done.)



          (* * rht 11/1/86: Added missing var binding.)


    (DECLARE (GLOBALVARS NC.MsgDelay NC.DatabaseFileNameSuggestion))
    (PROG ((MsgWindow Window)
	     Result FullFromFileName NoteFile)
	    (if (type? NoteFile FromNoteFileOrName)
		then (SETQ FullFromFileName (fetch (NoteFile FullFileName) of 
									       FromNoteFileOrName))
		       (SETQ MsgWindow (OR (WFROMMENU (fetch (NoteFile Menu) of 
									       FromNoteFileOrName))
					       Window))
	      else (OR FromNoteFileOrName (SETQ FromNoteFileOrName
			     (NC.DatabaseFileName "Name of NoteFile to be copied:" " -- " T NIL NIL 
						    MsgWindow))
			   (RETURN))
		     (SETQ FullFromFileName (FULLNAME FromNoteFileOrName))
		     (if (SETQ NoteFile (NC.NoteFileFromFileName FullFromFileName))
			 then (SETQ MsgWindow (OR (WFROMMENU (fetch (NoteFile Menu)
									of NoteFile))
							Window))))
	    (if (OPENP FullFromFileName)
		then (NC.PrintMsg MsgWindow T "Can't copy an open notefile." (CHARACTER 13))
		       (DISMISS NC.MsgDelay)
		       (NC.ClearMsg MsgWindow T)
		       (RETURN NIL))
	    (OR ToFileName (SETQ ToFileName (NC.DatabaseFileName "Name of target of copy:" 
								       " -- "
								       T NIL NIL MsgWindow))
		  (RETURN))
	    (COND
	      ((AND FullFromFileName ToFileName)
		(NC.PrintMsg MsgWindow T "Copying " FullFromFileName " to " ToFileName " ...")
		(COND
		  ((SETQ Result (COPYFILE FullFromFileName ToFileName))
		    (NC.PrintMsg MsgWindow T FullFromFileName " copied to " Result "."
				   (CHARACTER 13))
		    (SETQ NC.DatabaseFileNameSuggestion (PACKFILENAME (QUOTE VERSION)
									  NIL
									  (QUOTE BODY)
									  Result))
		    (DISMISS NC.MsgDelay)
		    (NC.ClearMsg MsgWindow T))))
	      ((NULL FullFromFileName)
		(NC.PrintMsg MsgWindow T "Can't open file for copy: " FromNoteFileOrName
			       (CHARACTER 13))
		(DISMISS NC.MsgDelay)
		(NC.ClearMsg MsgWindow T))))))

(NC.RenameNoteFile
  (LAMBDA (FromNoteFileOrName ToFileName Window)             (* rht: " 1-Nov-86 18:20")

          (* * Rename a notefile. Ask user for names of FromNoteFileOrName and ToFileName.)



          (* * fgh 7/5/86 First created on basis of CopyNoteFile.)



          (* * rht 11/1/86: Added missing var binding.)


    (DECLARE (GLOBALVARS NC.MsgDelay NC.DatabaseFileNameSuggestion))
    (PROG ((MsgWindow Window)
	     Result FullFromFileName NoteFile)
	    (if (type? NoteFile FromNoteFileOrName)
		then (SETQ FullFromFileName (fetch (NoteFile FullFileName) of 
									       FromNoteFileOrName))
		       (SETQ MsgWindow (OR (WFROMMENU (fetch (NoteFile Menu) of 
									       FromNoteFileOrName))
					       Window))
	      else (OR FromNoteFileOrName (SETQ FromNoteFileOrName
			     (NC.DatabaseFileName "Name of NoteFile to be renamed:" " -- " T NIL 
						    NIL MsgWindow))
			   (RETURN))
		     (SETQ FullFromFileName (FULLNAME FromNoteFileOrName))
		     (if (SETQ NoteFile (NC.NoteFileFromFileName FullFromFileName))
			 then (SETQ MsgWindow (OR (WFROMMENU (fetch (NoteFile Menu)
									of NoteFile))
							Window))))
	    (if (OPENP FullFromFileName)
		then (NC.PrintMsg MsgWindow T "Can't rename an open notefile." (CHARACTER
					13))
		       (DISMISS NC.MsgDelay)
		       (NC.ClearMsg MsgWindow T)
		       (RETURN NIL))
	    (OR ToFileName (SETQ ToFileName (NC.DatabaseFileName "New name for the NoteFile:" 
								       " -- "
								       T NIL NIL MsgWindow))
		  (RETURN))
	    (COND
	      ((AND FullFromFileName ToFileName)
		(NC.PrintMsg MsgWindow T "Renaming " FullFromFileName " to " ToFileName " ...")
		(COND
		  ((SETQ Result (RENAMEFILE FullFromFileName ToFileName))
		    (NC.PrintMsg MsgWindow T FullFromFileName " renamed to " Result "."
				   (CHARACTER 13))

          (* * Fix up the NoteFile with the new name.)


		    (AND NoteFile (replace (NoteFile FullFileName) of NoteFile with Result)
			   (AND (fetch (NoteFile Menu) of NoteFile)
				  (WFROMMENU (fetch (NoteFile Menu) of NoteFile))
				  (NC.SetUpNoteFileInterface NoteFile)))
		    (SETQ NC.DatabaseFileNameSuggestion (PACKFILENAME (QUOTE VERSION)
									  NIL
									  (QUOTE BODY)
									  Result))
		    (DISMISS NC.MsgDelay)
		    (NC.ClearMsg MsgWindow T))))
	      ((NULL FullFromFileName)
		(NC.PrintMsg MsgWindow T "Can't open file for rename: " FromNoteFileOrName
			       (CHARACTER 13))
		(DISMISS NC.MsgDelay)
		(NC.ClearMsg MsgWindow T))))))
)
(* * Changes to NCREPAIR)

(DEFINEQ

(NC.RobustRead
  (LAMBDA (Stream)                                           (* rht: " 1-Nov-86 15:21")

          (* * Try to read an object, In an NLSETQ so we won't see error messages. The RESETVAR is so that no breaks will 
	  occur. This returns list of the one element read or NIL if unsuccessful read.)



          (* * rht 11/1/86: Now uses our readtable when reading.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (RESETVAR HELPFLAG NIL (NLSETQ (READ Stream NC.OrigReadTable)))))
)
(* * Changes to NCBROWSERCARD)

(DEFINEQ

(NC.WriteBrowserLinkLabels
  (LAMBDA (Stream LinkLabels)                                (* rht: " 1-Nov-86 15:37")

          (* * Write list of link labels from notefile.)



          (* * rht 11/1/86: Now uses our readtable when printing.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (PRINT LinkLabels Stream NC.OrigReadTable)))

(NC.WriteBrowserFormat
  (LAMBDA (Stream Format)                                    (* rht: " 1-Nov-86 15:37")

          (* * Write browser format to notefile.)



          (* * rht 11/1/86: Now uses our readtable when printing.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (PRINT Format Stream NC.OrigReadTable)))

(NC.WriteSpecialBrowserSpecs
  (LAMBDA (Stream LinkLabels)                                (* rht: " 1-Nov-86 15:38")

          (* * Write special browser specs to notefile.)



          (* * rht 11/1/86: Now uses our readtable when printing.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (PRINT LinkLabels Stream NC.OrigReadTable)))

(NC.WriteBrowserDepth
  (LAMBDA (Stream Depth)                                     (* rht: " 1-Nov-86 15:38")

          (* * Write depth to notefile.)



          (* * rht 11/1/86: Now uses our readtable when printing.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (PRINT Depth Stream NC.OrigReadTable)))

(NC.WriteBrowserLinksLegend
  (LAMBDA (Stream LinksLegend)                               (* rht: " 1-Nov-86 15:38")

          (* * Write links legend to notefile.)



          (* * rht 11/1/86: Now uses our readtable when printing.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (PRINT LinksLegend Stream NC.OrigReadTable)))

(NC.WriteBrowserSavedLinkingInfoForNode
  (LAMBDA (Stream BrowserSavedLinkingInfoForNode)            (* rht: " 1-Nov-86 15:39")

          (* * Write list of info on multiple links for a particular node. In form of a source UID cons'ed to a prop list of 
	  destination UIDs and link dashing info.)



          (* * rht 11/1/86: Now uses our readtable when printing.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (PRIN1 (QUOTE %()
	     Stream)
    (NC.WriteUID Stream (CAR BrowserSavedLinkingInfoForNode))
    (for SavedLinkInfo on (CDR BrowserSavedLinkingInfoForNode) by (CDDR SavedLinkInfo)
       eachtime (BLOCK)
       do (NC.WriteUID Stream (CAR SavedLinkInfo))
	    (PRINT (CADR SavedLinkInfo)
		     Stream NC.OrigReadTable))
    (PRIN1 (QUOTE %))
	     Stream)))
)
(DEFINEQ

(NC.ReadBrowserLinkLabels
  (LAMBDA (Stream)                                           (* rht: " 1-Nov-86 15:43")

          (* * Read list of link labels from notefile.)



          (* * rht 11/1/86: Now uses our readtable when reading.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (PROG1 (READ Stream NC.OrigReadTable)
	     (BIN Stream))))

(NC.ReadBrowserFormat
  (LAMBDA (Stream)                                           (* rht: " 1-Nov-86 15:43")

          (* * Read browser format from notefile.)



          (* * rht 11/1/86: Now uses our readtable when reading.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (PROG1 (READ Stream NC.OrigReadTable)
	     (BIN Stream))))

(NC.ReadSpecialBrowserSpecs
  (LAMBDA (Stream)                                           (* rht: " 1-Nov-86 15:44")

          (* * Read special browser specs from notefile.)



          (* * rht 11/1/86: Now uses our readtable when reading.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (PROG1 (READ Stream NC.OrigReadTable)
	     (BIN Stream))))

(NC.ReadBrowserDepth
  (LAMBDA (Stream)                                           (* rht: " 1-Nov-86 15:44")

          (* * Read depth from notefile.)



          (* * rht 11/1/86: Now uses our readtable when reading.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (LET ((ThingRead (READ Stream NC.OrigReadTable)))
         (if (NOT (FIXP ThingRead))
	     then (NC.ReportError "NC.ReadBrowserFormat" (CONCAT 
							      "Expected to read a number.  Saw: "
								       ThingRead)))
                                                             (* Skip CR)
         (BIN Stream)
     ThingRead)))

(NC.ReadBrowserLinksLegend
  (LAMBDA (Stream)                                           (* rht: " 1-Nov-86 15:44")

          (* * Read links legend from notefile.)



          (* * rht 11/1/86: Now uses our readtable when reading.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (PROG1 (READ Stream NC.OrigReadTable)
	     (BIN Stream))))

(NC.ReadBrowserSavedLinkingInfoForNode
  (LAMBDA (Stream)                                           (* rht: " 1-Nov-86 15:45")

          (* * Read list of info on multiple links for a particular node. In form of a source UID cons'ed to a prop list of 
	  destination UIDs and link dashing info.)



          (* * rht 11/1/86: Now uses our readtable when reading.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (LET (CharRead SourceUID)
         (if (NEQ (SETQ CharRead (CHARACTER (BIN Stream)))
		      (QUOTE %())
	     then (NC.ReportError "NC.ReadBrowserSavedLinkingInfoForNode" (CONCAT 
						       "Expected to read left paranthesis. Saw: "
											CharRead)))
         (PROG1 (CONS (NC.ReadUID Stream)
			  (while (NEQ (CHARACTER (\PEEKBIN Stream))
					  (QUOTE %)))
			     eachtime (BLOCK) join (PROG1 (LIST (NC.ReadUID Stream)
									  (READ Stream 
										 NC.OrigReadTable))
                                                             (* Skip CR)
								  (BIN Stream))))
                                                             (* Skip RightParen)
		  (BIN Stream)))))
)
(* * Changes to NCSKETCHCARD)

(DEFINEQ

(NC.PutSketchSubstance
  (LAMBDA (Card Stream)                                      (* rht: " 1-Nov-86 15:52")

          (* Put the sketch substance for card ID to the database. Store the global sketch descriptor, the scale and region 
	  viewed for ID and any cached bit maps.)



          (* * fgh 11/14/85 Updated to handle Card object.)



          (* * fgh 11/20/85 NoteCards now takes care of setting the start and end pointers for the substance.)



          (* * rht 1/23/86: Now takes Stream as arg instead of computing from Card.)



          (* * fgh 2/6/86 Now returns version number.)



          (* * fgh&rht 8/25/86 Changed call to NC.PutCachedMap to remove use of SCREENELT record.)



          (* * rht&pmi 10/15/86: Changed outdated SK.REGION.VIEWED call to SKETCH.REGION.VIEWED.)



          (* * rht 11/1/86: Now uses our readtable when printing.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (LET ((Substance (NC.FetchSubstance Card))
	  (Window (NC.FetchWindow Card)))
         (HPRINT Substance Stream NIL T)
         (PRINT (OR (AND Window (SCALE.FROM.SKW Window))
			(NC.FetchScale Card))
		  Stream NC.OrigReadTable)
         (PRINT (OR (AND Window (SKETCH.REGION.VIEWED Window))
			(NC.FetchRegionViewed Card))
		  Stream NC.OrigReadTable)
         (AND Window (for Element in (SKETCH.LIST.OF.ELEMENTS (INSURE.SKETCH Substance)
								      (FUNCTION (LAMBDA (Element)
									  (EQ (
									     GETSKETCHELEMENTPROP
										  Element
										  (QUOTE TYPE))
										(QUOTE MAP))))
								      T)
			  do (NC.PutCachedMap Element Window Stream)))
         (PRINT (QUOTE ###ENDSKETCH###)
		  Stream NC.OrigReadTable)
     0)))

(NC.PutCachedMap
  (LAMBDA (SketchMapElement SketchWindow Stream)             (* rht: " 1-Nov-86 15:52")
                                                             (* Put a cached bit map corresponding to MapScreenElt 
							     onto database file)

          (* * 8/25/86 fgh&rht Removed use of SCREENELT record and replaced with call to CacheSpecsFromMapSketchElement which
	  is defined in the MAP package.)



          (* * rht 11/1/86: Now uses our readtable when printing.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (LET (CacheSpecs BitMap)
         (AND (LISTP (SETQ CacheSpecs (CacheSpecsFromMapSketchElement SketchMapElement 
									    SketchWindow)))
		(for CacheSpec in CacheSpecs
		   do (BITMAPP (SETQ BitMap (APPLY (FUNCTION FetchCachedBitMap)
							   CacheSpec)))
			(PRINT (QUOTE ###CACHEDMAP###)
				 Stream NC.OrigReadTable)
			(PRINT CacheSpec Stream NC.OrigReadTable)
			(HPRINT BitMap Stream T T))))))
)
(DEFINEQ

(NC.GetSketchSubstance
  (LAMBDA (Card Length Stream)                               (* rht: " 1-Nov-86 15:54")

          (* Get sketch substance from Database stream. Database stream is positioned. READ the global sketch description, 
	  the locasl sketch scale and region viewed. Also read in any cached bit maps for the MAPS system.)



          (* * fgh 11/14/85 Updated to handle Card and NoteFile objects.)



          (* * fgh 11/20/85 NoteCards now passes start and enptrs down.)



          (* * fgh 11/21/85 Now passed Length instead of start and end ptrs.)



          (* * rht 1/23/86: Now takes Stream as arg instead of computing from Card.)



          (* * rht 11/1/86: Now uses our readtable when reading.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (LET (Sketch Scale RegionViewed)

          (* * Get the substance)


         (SETQ Sketch (HREAD Stream))
         (SETQ Scale (READ Stream NC.OrigReadTable))
         (SETQ RegionViewed (READ Stream NC.OrigReadTable))
         (while (EQ (READ Stream NC.OrigReadTable)
			(QUOTE ###CACHEDMAP###))
	    do (NC.GetCachedMap Stream))
         (LIST Sketch Scale RegionViewed))))

(NC.GetCachedMap
  (LAMBDA (Stream)                                           (* rht: " 1-Nov-86 15:54")
                                                             (* Read a bit map from the file and then put it onto 
							     the cached maps list)

          (* * FGH 9/28/85 Updated to handle new map changes. In particular, caching now done on the map resolution and noit 
	  on the x and y offsets.)



          (* * rht 10/10/86: Replaced APPLY of SetCachedBitMap with NC.AutoloadApply so that NCMAPS will get autoloaded.)



          (* * rht 11/1/86: Now uses our readtable when reading.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (LET (CacheSpecs BitMap)
         (SETQ CacheSpecs (READ Stream NC.OrigReadTable))
         (COND
	   ((EQ (LENGTH CacheSpecs)
		  8)

          (* * Old Scheme for cahcing)


	     (SETQ CacheSpecs (CONS (QUOTE HIGH)
					(CDDR CacheSpecs)))))
         (SETQ BitMap (HREAD Stream))
         (AND CacheSpecs BitMap (NC.AutoloadApply (FUNCTION SetCachedBitMap)
						    (CONS BitMap CacheSpecs))))))
)
(* * Changes to NCLISTCARD)

(DEFINEQ

(NC.ListCardPutFn
  (LAMBDA (Card Stream)                                      (* rht: " 1-Nov-86 15:57")
                                                             (* Put list substance)

          (* * fgh 11/20/85 NoteCards now takes care of setting the start and end pointers for the substance.)



          (* * rht 1/23/86: Now takes Stream as arg instead of computing from Card.)



          (* * fgh 2/6/86 Now returns version number.)



          (* * rht 11/1/86: Now uses our readtable when printing.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (PRINT (NC.FetchSubstance Card)
	     Stream NC.OrigReadTable)
    0))
)
(DEFINEQ

(NC.ListCardGetFn
  (LAMBDA (Card Length Stream)                               (* rht: " 1-Nov-86 15:57")

          (* * Get the list substance from the disk)



          (* * fgh 11/20/85 NoteCards now passes start and end ptrs down.)



          (* * fgh 11/21/85 Now passes length instead of start and end ptrs.)



          (* * rht 1/23/86: Now takes Stream as arg instead of computing from Card.)



          (* * rht 11/1/86: Now uses our readtable when reading.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (READ Stream NC.OrigReadTable)))
)
(* * Changes to NCREGISTRYCARD)

(DEFINEQ

(NC.RegistryCardPutFn
  (LAMBDA (Card Stream)                                      (* rht: " 1-Nov-86 16:08")

          (* * Puts Registry substance to notefile. Writes down atomic key followed by UID for each hash table pair.
	  Writes down special marker at the end.)



          (* * rht 11/1/86: Now uses our readtable when printing.)


    (DECLARE (GLOBALVARS NC.OrigReadTable NC.RegistrySubstanceEndMarker))
    (MAPHASH (NC.FetchSubstance Card)
	       (FUNCTION (LAMBDA (Value Item)
		   (PRINT Item Stream)
		   (NC.WriteUID Stream Value))))
    (PRINT NC.RegistrySubstanceEndMarker Stream NC.OrigReadTable)
    0))
)
(DEFINEQ

(NC.RegistryCardGetFn
  (LAMBDA (Card Length Stream)                               (* rht: " 1-Nov-86 16:06")

          (* * Get the Registry substance from the disk)



          (* * rht 11/1/86: Now uses our readtable when reading.)


    (DECLARE (GLOBALVARS NC.OrigReadTable NC.RegistrySubstanceEndMarker 
			     NC.DefaultRegistryCardHashArraySize))
    (LET ((HashArray (HASHARRAY NC.DefaultRegistryCardHashArraySize))
	  (EndLoc (PLUS Length (GETFILEPTR Stream))))
         (for bind Key eachtime (BLOCK) while (LESSP (GETFILEPTR Stream)
								 EndLoc)
	    until (EQ (SETQ Key (READ Stream NC.OrigReadTable))
			  NC.RegistrySubstanceEndMarker)
	    do                                             (* Skip CR)
		 (BIN Stream)
		 (PUTHASH Key (NC.ReadUID Stream)
			    HashArray))
     HashArray)))
)
(* * Changes to NCCROSSFILELINKS)

(DEFINEQ

(NC.CrossFileLinkPutFn
  (LAMBDA (Card Stream)                                      (* rht: " 1-Nov-86 16:03")

          (* * Put crossfilelink substance)



          (* * rht 11/1/86: Now uses our readtable when printing.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (LET ((Substance (NC.FetchSubstance Card)))
         (NC.WriteUID Stream (fetch (CrossFileLinkSubstance CrossFileLinkDestCardUID)
				  of Substance))
         (NC.WriteUID Stream (fetch (CrossFileLinkSubstance CrossFileLinkDestNoteFileUID)
				  of Substance))
         (PRINT (fetch (CrossFileLinkSubstance CrossFileLinkDestFileHint) of Substance)
		  Stream NC.OrigReadTable))
    0))
)
(DEFINEQ

(NC.CrossFileLinkGetFn
  (LAMBDA (Card Length Stream)                               (* rht: " 1-Nov-86 16:04")

          (* * Get the crossfilelink substance from the disk)



          (* * rht 11/1/86: Now uses our readtable when reading.)


    (DECLARE (GLOBALVARS NC.OrigReadTable))
    (create CrossFileLinkSubstance
	      CrossFileLinkDestCardUID ←(NC.ReadUID Stream)
	      CrossFileLinkDestNoteFileUID ←(NC.ReadUID Stream)
	      CrossFileLinkDestFileHint ←(READ Stream NC.OrigReadTable))))
)
(PUTPROPS RHTPATCH130 COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (2893 4860 (NC.BuildVerticalBarREADTABLE 2903 . 3489) (NC.DisassembleUID 3491 . 4858)) (
4861 9673 (NC.WriteIdentifier 4871 . 5747) (NC.WriteListOfLinks 5749 . 6462) (NC.WriteDate 6464 . 6991
) (NC.WriteCardType 6993 . 7464) (NC.WriteTitle 7466 . 7923) (NC.WritePropList 7925 . 8392) (
NC.WriteLink 8394 . 9671)) (9674 16390 (NC.ReadListOfLinks 9684 . 10498) (NC.ReadIdentifier 10500 . 
12067) (NC.ReadDate 12069 . 13154) (NC.ReadCardType 13156 . 13707) (NC.ReadTitle 13709 . 14156) (
NC.ReadPropList 14158 . 14612) (NC.ReadLink 14614 . 16388)) (16391 26538 (NC.FixUpLinksInCardCopy 
16401 . 21002) (NC.CopyNoteFile 21004 . 23729) (NC.RenameNoteFile 23731 . 26536)) (26571 27116 (
NC.RobustRead 26581 . 27114)) (27154 29833 (NC.WriteBrowserLinkLabels 27164 . 27529) (
NC.WriteBrowserFormat 27531 . 27881) (NC.WriteSpecialBrowserSpecs 27883 . 28250) (NC.WriteBrowserDepth
 28252 . 28591) (NC.WriteBrowserLinksLegend 28593 . 28951) (NC.WriteBrowserSavedLinkingInfoForNode 
28953 . 29831)) (29834 33292 (NC.ReadBrowserLinkLabels 29844 . 30229) (NC.ReadBrowserFormat 30231 . 
30607) (NC.ReadSpecialBrowserSpecs 30609 . 30998) (NC.ReadBrowserDepth 31000 . 31665) (
NC.ReadBrowserLinksLegend 31667 . 32046) (NC.ReadBrowserSavedLinkingInfoForNode 32048 . 33290)) (33329
 36217 (NC.PutSketchSubstance 33339 . 35181) (NC.PutCachedMap 35183 . 36215)) (36218 38640 (
NC.GetSketchSubstance 36228 . 37484) (NC.GetCachedMap 37486 . 38638)) (38675 39369 (NC.ListCardPutFn 
38685 . 39367)) (39370 39980 (NC.ListCardGetFn 39380 . 39978)) (40019 40710 (NC.RegistryCardPutFn 
40029 . 40708)) (40711 41633 (NC.RegistryCardGetFn 40721 . 41631)) (41674 42413 (NC.CrossFileLinkPutFn
 41684 . 42411)) (42414 42967 (NC.CrossFileLinkGetFn 42424 . 42965)))))
STOP