(FILECREATED " 9-May-87 21:22:47" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH258.;3 5688   

      changes to:  (VARS RHTPATCH258COMS)
		   (FNS BMOBJ.GETFN3 NC.RobustGetSubstance NC.ReportError)

      previous date: " 8-May-87 14:23:03" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH258.;1)


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

(PRETTYCOMPRINT RHTPATCH258COMS)

(RPAQQ RHTPATCH258COMS ((DECLARE: FIRST (P (NC.LoadFileFromDirectories (QUOTE NCREPAIR))))
			  (* * This prevents NC.ReportError from breaking when HELPFLAG is nil. Also 
			     changes inspector to properly hang HELPFLAG when reading substances. 
			     Also, fixes bug where good browsers were claimed by inspect&repair to be 
			     bad. Also fixes %#534 seems that BMOBJ.GETFN3 is buggy, but in a very 
			     mysterious way. I replaced calls to \WIN with the equivalent PLUS of LSH 
			     of BIN with BIN and it works. WEIRD!)
			  (* * Change to NCREPAIR)
			  (FNS NC.RobustGetSubstance NC.CheckForValidSubstance)
			  (* * Change to NCUTILITIES)
			  (FNS NC.ReportError)
			  (* * New function for KOTOTEDITPATCHES)
			  (FNS BMOBJ.GETFN3)))
(DECLARE: FIRST 
(NC.LoadFileFromDirectories (QUOTE NCREPAIR))
)
(* * This prevents NC.ReportError from breaking when HELPFLAG is nil. Also changes inspector 
to properly hang HELPFLAG when reading substances. Also, fixes bug where good browsers were 
claimed by inspect&repair to be bad. Also fixes %#534 seems that BMOBJ.GETFN3 is buggy, but in 
a very mysterious way. I replaced calls to \WIN with the equivalent PLUS of LSH of BIN with BIN
 and it works. WEIRD!)

(* * Change to NCREPAIR)

(DEFINEQ

(NC.RobustGetSubstance
  (LAMBDA (Card Length Stream SubstanceVersion)              (* rht: " 8-May-87 14:20")

          (* * Try to get substance robustly. RESETVAR prevents breaks. Returns either substance or nil if unsuccessful.)



          (* * rht 12/1/85: Updated to use card and notefile format.)



          (* * fgh 2/5/86 Added call to NC.ApplyFn)



          (* * rht 3/22/86: Now passes substance version %#s and Stream to GetFn.)



          (* * rht 5/8/87: Changed to use LET rather than RESETVAR to temporarily nullify HELPFLAG value.)


    (LET ((HELPFLAG NIL))
         (NLSETQ (NC.ApplyFn GetFn Card Length Stream SubstanceVersion)))))

(NC.CheckForValidSubstance
  (LAMBDA (Stream EofPtr Card CardType ReadSubstanceFlg)     (* rht: " 9-May-87 18:23")

          (* * Check whether we've got a valid substance at current pos in Stream. Check for a valid StartPtr and EndPtr.
	  If ReadSubstanceFlg is non-nil, then do robust get of the substance. Return length of substance or nil.)



          (* * rht 12/1/85: Updated to handle new notefile format in MainCardData card part.)



          (* * rht 3/22/86: Now handles substance version numbers.)



          (* * rht 5/9/87: Now sets card type in card object because the call to NC.ApplyFn was calling NC.GetType and 
	  screwing up our file ptr.)


    (LET ((OldPtr (GETFILEPTR Stream))
	  Length EndPtr)
         (OR EofPtr (SETQ EofPtr (GETEOFPTR Stream)))
         (if (AND (LESSP OldPtr (DIFFERENCE EofPtr 3))
		      (SETQ Length (NC.ReadPtr Stream 3))
		      (LEQ (SETQ EndPtr (PLUS OldPtr 4 Length))
			     EofPtr)
		      (OR (NOT ReadSubstanceFlg)
			    (NOT (NCP.ValidCardType CardType))
			    (PROGN (NC.SetType Card CardType)
				     (NC.RobustGetSubstance Card Length Stream (NC.ReadPtr Stream 1)
							      )))
		      (SETFILEPTR Stream EndPtr)
		      Length)
	   else (SETFILEPTR Stream OldPtr)
		  NIL))))
)
(* * Change to NCUTILITIES)

(DEFINEQ

(NC.ReportError
  (LAMBDA (FromFunction Msg)                                 (* rht: " 8-May-87 14:13")

          (* * fgh 9/4/86 If \NC.NoBreakInReportError is non-NIL just prints msg in prompt window and cause ERROR!.)



          (* * rht 3/2/87: coerced the function name to be an atom to fix a bug showing up in lyric.)



          (* * rht 5/8/87: No longer breaks if HELPFLAG is nil.)


    (DECLARE (GLOBALVARS \NC.NoBreakInReportError))
    (if HELPFLAG
	then (if \NC.NoBreakInReportError
		   then (FLASHW PROMPTWINDOW)
			  (CLRPROMPT)
			  (PROMPTPRINT "NoteCards Error")
			  (PROMPTPRINT Msg)
			  (ERROR!)
		 else (APPLY* (FUNCTION BREAK1)
				  T T (MKATOM FromFunction)
				  NIL NIL (LIST Msg))))))
)
(* * New function for KOTOTEDITPATCHES)

(DEFINEQ

(BMOBJ.GETFN3
  (LAMBDA (STREAM)                                           (* rht: " 9-May-87 21:18")
                                                             (* ;;; 
							     
"reads a bitmap image object from a file.  This version stores the binary data rather than the character representation used by READBITMAP."
)
    (COND
      ((IEQP (\PEEKBIN STREAM)
	       (CHARCODE CR))                              (* ; 
							     
"This is an old-format sketch with bitmap included.  Skip the interfering CR.")
	(BIN STREAM)))
    (PROG ((SCALE (FPLUS (PLUS (LSH (BIN STREAM)
					    8)
				     (BIN STREAM))
			     (FQUOTIENT (PLUS (LSH (BIN STREAM)
							 8)
						  (BIN STREAM))
					  32768)))
	     (ROT (PLUS (LSH (BIN STREAM)
				   8)
			    (BIN STREAM))))
	    (RETURN (BITMAPTEDITOBJ (\READBINARYBITMAP STREAM)
					SCALE ROT)))))
)
(PUTPROPS RHTPATCH258 COPYRIGHT ("Xerox Corporation" 1987))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (1645 3723 (NC.RobustGetSubstance 1655 . 2348) (NC.CheckForValidSubstance 2350 . 3721)) 
(3758 4573 (NC.ReportError 3768 . 4571)) (4620 5606 (BMOBJ.GETFN3 4630 . 5604)))))
STOP