KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Maximum Number of Resources in a File
PRODUCT: 4D | VERSION: | PLATFORM:
Published On: December 3, 1999

If you like to add custom resources to your database projects, you should keep in mind that there is a maximum limit of 2700 individual resources that you can have in one file. (This is documented in the 4th Dimension Language Reference, in Chapter 40 "Resources," in a Warning in the "Resource Type" section.) If you exceed this limit, the resource file will become damaged the first time you use it. The result of this is that upon subsequent efforts to open the database, it immediately quits (before displaying any password dialog). This is the same symptom you would get if the resource file was missing.

Since a 4D structure resource file contains only two resources by default, it would seem like you are a long way off from exceeding the limit. (On Macintosh, this term "structure resource file" refers to the resource fork of the structure file. On Windows it refers to the ".RSR" file of the database.) But when you compile and merge with 4D Engine, all the resources that would otherwise reside in a separate resource file for the 4D application are merged together into the resource file for the 4D structure. For example, the resulting resource file from a compile and merge with 4D Engine v6.5.2 for Windows will have a minimum of 2545 individual resources in it. (The Macintosh version will contain at least 2532 resources.) This means that if you added over 155 of your own custom resource items, you would exceed the limit.

If you want to have a large number of custom resource items in a database to be merged with 4D Engine, you should consider moving them into a separate resource file, which your startup code can open with the "Open resource file" command.

To count the number of individual resources in a file, you need to count how many items there are of each resource type, and add them all together. For example, if you use the utility ResEdit to open a Macintosh file's resource fork, you will see a list of the different resource types in the file. Each of these resource types can contain multiple individual resources of that type. The 4D Language Reference Manual, under the description of the "RESOURCE TYPE LIST" command, includes sample code that will count the total number of individual resources in a file.