In classic Mac OS, a resource is a reusable data element which is stored as simple data in a separate fork
of the file, called the resource fork
. As many data elements as you want, of practically any type you want, can be easily created in the ResEdit
program and saved in a file which is assumed into your program at compile
time. Each resource has a four-letter type, depending on what it is; types which are used commonly include menu
s ('MENU'), dialog
s ('DLOG', 'DITL', etc.), picture
s ('PICT'), icon
s ('ICON', 'ICN#', 'ic18', 'cicn', 'icns', etc.), string
s ('STR '), and, well, practically everything else. On the 680X0
you could even have executable machine code
This approach has a couple of nice advantages. First off, you are able to separate your data from your executable code in a nice, organized manner, and the Resource Manager provides an easy, high-level approach to handling and dealing with said data. Second off you are able to store practically all relevant information and data inside your program, meaning you can write a huge mac program that is just one single file. This is a lot easier to handle and move around than your average windows program, which has 30 or so random binary data files and a bunch of weird arbitrary directories. Sadly in recent years mac apps have started to rely more and more on messy separate files, but that's another story..
The other advantage is that it's just as easy to modify resources inside a program that's already been compiled as it is to modify resources inside a program that hasn't been compiled yet.. and you do it with the same tool. Meaning you can open up pretty much any mac program in the excellent tool ResEdit and change almost any reusable data element, such as dialog boxes or icons. You can do some vaguely interesting things like this-- i once opened up the game Civilization and discovered that the names of everything relevant-- leaders, countries, the Barbarians, technologies, everything-- were stored as a series of 'STR#' (string array) resources. So i went in and renamed everything.. it was interesting.
Under Mac OS X, the resource fork has been replaced by the concept of the package-- please see Resource Fork, Package, or Property list. The system, however, and in fact all carbon applications, still make heavy use though of ".rsrc" files, which are nothing more than the contents of a legitimate resource fork stored as normal binary data within a data fork.