[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re- ostype

From: STEVE.M@AppleLink.Apple.Com@INTERNET#
Subject: Re- :ostype, auto font lock, and 2.0 ?'s + thanks
To: info-macl@cambridge.apple.com
> 1) I would like to use the :ostype keyword for stack trap calls but it
>    needs "A four-character string or symbol with a four-character print
>    name" (p185) and all I have is a symbol whose value is what I'd like
>    to be passed. Any suggestions on how to make this work from a function?
One way is to NOT use the :ostype keyword:
(defun Type-to-words (Type-s)
   "Converts an OSType or ResType (4 char) string to a list of 2 words."
   ;"clut" -> (#x636C #x7574)   Note: reverse the components when pass to
   (list (+ (* 256 (char-code (aref Type-s 0))) (char-code (aref Type-s 1)))
         (+ (* 256 (char-code (aref Type-s 2))) (char-code (aref Type-s 3)))))
(defun Count-Resources (Res-type-s)
   "Counts the (non-ROM) resources of (4 char) Res-type-s in the resource map."
   (let ((Res-type-list (Type-to-words Res-type-s)))
      (_CountResources :word (cadr Res-type-list) :word (car Res-type-list)
(Count-Resources "clut") -> 1