home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / sys / mac / programm / 22119 < prev    next >
Encoding:
Text File  |  1993-01-25  |  2.9 KB  |  76 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!paladin.american.edu!howland.reston.ans.net!sol.ctr.columbia.edu!sol.ctr.columbia.edu!mhall
  3. From: mhall@occs.cs.oberlin.edu (Matthew Hall)
  4. Subject: Re: Resources
  5. In-Reply-To: keith@taligent.com's message of Mon, 25 Jan 1993 01:50:12 GMT
  6. Followup-To: comp.sys.mac.programmer
  7. References: <rudolph.727824463@unixg.ubc.ca> <keith-240193173900@kip-50.taligent.com>
  8. Sender: nobody@ctr.columbia.edu
  9. Organization: Oberlin College Computer Science
  10. Date: Mon, 25 Jan 1993 13:40:51 GMT
  11. Message-ID: <MHALL.93Jan25084051@occs.cs.oberlin.edu>
  12. X-Posted-From: occs.cs.oberlin.edu
  13. NNTP-Posting-Host: sol.ctr.columbia.edu
  14. Lines: 60
  15.  
  16. In article <keith-240193173900@kip-50.taligent.com> keith@taligent.com (Keith Rollin) writes:
  17.  
  18. >   In article <rudolph.727824463@unixg.ubc.ca>, rudolph@unixg.ubc.ca
  19. >   (Christopher E Rudolph) wrote:
  20. >   > 
  21. >   > Can anyone tell me if there is an quick way of opening an applications
  22. >   > resource fork and then cycling through every resource in the application
  23. >   > so that I can display them in a list.
  24. >   > 
  25. >   > ie) simaler to what resource editors do
  26. >   > 
  27. >   > I basically want to know what methods are available to read off every
  28. >   > resource in an applications resource fork?
  29. >   > 
  30. >
  31. >   The right way is to go back to Inside Mac IV and read the descriptions of
  32. >   the functions Get1IndType, Get1IndResource, Count1Types and
  33. >   Count1Resources. You would then write a function sort of like the
  34. >   following:
  35. >
  36. >   short numTypes, numResources, typeIndex, resIndex;
  37. >   ResType type;
  38. >   Handle resource;
  39. >
  40. >   numTypes = Count1Types();
  41. >   for (typeIndex = 1; numIndex <= numTypes; ++typeIndex)
  42. >   {
  43. >       Get1IndType(&type, typeIndex);
  44. >       numResources = Count1Resources(type);
  45. >       for (resIndex = 1; resIndex <= resTypes; ++resIndex)
  46. >       {
  47. >       resource = Get1IndResource(type, resIndex);
  48. >       MessWithResource(resource);
  49. >       }
  50. >   }
  51.  
  52. You will speed it up Much More, if you bracket this code with
  53. SetResLoad(FALSE)..SetResLoad(TRUE), since the resource manager will
  54. not read in the resource, but just it's name, number, and (size?),
  55. Thereby cutting down on possible disk access and memory useage.  Of
  56. course, if you need to manipulate or read data from a resource, you
  57. will have to load it in by calling LoadResource, or if you saved the
  58. handle, GetResource.
  59. Just a note - be sure to call SetResLoad(TRUE) before doing anything
  60. that possibly might just perhaps use resources (such as manipulating a
  61. list, opening a window, jumping to a routine in another segment) since
  62. if these things have been purged or not loaded yet, they wont get
  63. loaded, and you may have a little mess on your hands.
  64.  
  65. Hope this helps,
  66. -matt hall
  67.  
  68.  
  69. --
  70. -------------------------------------------------------------------------------
  71. Matt Hall.    mhall@occs.oberlin.edu  OR  SMH9666@OBERLIN.BITNET
  72.               (216)-775-6613 (That's a Cleveland Area code. Lucky Me)
  73.  
  74.                          F(X)=M*X*(1-X)  
  75.  
  76.