(FILECREATED "27-May-86 20:54:56" {QV}<NOTECARDS>1.3K>FGHPATCH045.;1 3873   

      changes to:  (VARS FGHPATCH045COMS)
		   (FNS NC.ReadVersion2MainCardData))


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

(PRETTYCOMPRINT FGHPATCH045COMS)

(RPAQQ FGHPATCH045COMS ((* * Fix to converting browsers from NCCONVERTVERSION2TO3)
			  (FNS NC.ReadVersion2MainCardData)))
(* * Fix to converting browsers from NCCONVERTVERSION2TO3)

(DEFINEQ

(NC.ReadVersion2MainCardData
  (LAMBDA (Stream ID Card Version2HashArray FromNoteFile ToNoteFile)
                                                             (* fgh: "27-May-86 20:43")

          (* * Stream should be positioned at the main data card part of ID. Get the main data and fill in for Card.)



          (* * fgh 12/17/85 changed Apply of CollectReferencesFn to be done only if there is a CollectReferencesFn for the 
	  card type)



          (* * rht 5/7/86: Now only does the horrible kludge of smashing absolute pointers in the 1.2 file if the TEdit is 
	  judged to be formatted. We check that by looking for the TEdit password at the end of the substance.)



          (* * fgh 5/27/86 Added INTERSECTION call during conversion of links due to problems with browsers which have same 
	  link icon represented twice in the browser.)


    (LET (CardType Region StartPtr EndPtr Length TEditBasedFlg StartFormatPtr CollectReferencesFn 
		   FormattedTEditP LinkIcons)
         (NC.SetItemDate Card (NC.ReadVersion2CardPartHeader Stream ID NC.Version2ItemIdentifier))

          (* * Read card type and region)


         (NC.SetType Card (SETQ CardType (READ Stream)))
         (SETQ TEditBasedFlg (NC.TEditBasedP CardType))
         (READC Stream)
         (NC.SetRegion Card (NC.ReadVersion2Region Stream))

          (* * Read the substance pointers, compute the length, then call the substance get fn)


         (SETQ StartPtr (NC.ReadPtr Stream 3))
         (SETQ EndPtr (NC.ReadPtr Stream 3))
         (SETQ Length (DIFFERENCE EndPtr StartPtr))

          (* * Figure out whether the substance is TEdit formatted. In that case we have to smush absolute pointers.)


         (SETQ FormattedTEditP (AND TEditBasedFlg (GREATERP Length 2)
					(SETFILEPTR Stream (DIFFERENCE EndPtr 2))
					(EQ (QUOTIENT (NC.ReadPtr Stream 2)
							  100)
					      NC.TEditPasswordDividedBy100)))

          (* * A horrible kludge: Change the infamous file absolute pointer in the text stream to be file relative for 
	  duration of the GetSubstance call.)


         (if FormattedTEditP
	     then (SETFILEPTR Stream (DIFFERENCE EndPtr 8))
		    (SETQ StartFormatPtr (NC.ReadPtr Stream 4))
		    (SETFILEPTR Stream (DIFFERENCE EndPtr 8))
		    (NC.WritePtr Stream (DIFFERENCE StartFormatPtr StartPtr)
				 4))
         (SETFILEPTR Stream StartPtr)
         (NC.SetSubstance Card (NC.ApplyFn GetFn Card Length Stream -1))

          (* * Now put back the infamous file absolute pointer.)


         (if FormattedTEditP
	     then (SETFILEPTR Stream (DIFFERENCE EndPtr 8))
		    (NC.WritePtr Stream StartFormatPtr 4)
		    (SETFILEPTR Stream EndPtr))

          (* * Now convert each link in the embedded link icons in the substance.)


         (if (fetch (Card CollectLinksFn) of Card)
	     then (for LinkIcon in (INTERSECTION (SETQ LinkIcons
							   (CAR (NC.ApplyFn CollectLinksFn Card NIL 
									      T)))
							 LinkIcons)
		       eachtime (BLOCK) do (NC.ConvertVersion2LinkIcon LinkIcon Card 
									       Version2HashArray))))))
)
(PUTPROPS FGHPATCH045 COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (462 3791 (NC.ReadVersion2MainCardData 472 . 3789)))))
STOP