Futurebasic/Language/Reference/resources

SyntaxEdit

RESOURCES

RevisedEdit

May 30, 2000 (Release 3)

DescriptionEdit

This is a non-executable statement that performs two main functions: It specifies your program's file type and creator; It identifies an existing file (pathname) containing resources that should be copied into the resource fork of your application file or code resource file, when FB builds your file. The RESOURCES statement is optional. If you don't include it in your program, FB builds an application file of type "APPL", with creator signature "xxxx", containing a standard set of resources. Resources may also be added by dragging a resource file into the project manager window. You can include multiple RESOURCES statements in your program. FB uses the first encountered RESOURCES statement to determine the file type and creator. The pathname parameter can be a full or partial pathname which specifies a file that contains resources; or which specifies an alias to such a file. If you use a partial pathname (for example, a simple file name), the path is assumed to be relative to your project folder. When FB builds your application file, it copies all the resources from the pathname file into the resource fork of the file that it builds. Note that if you don't specify the pathname parameter, you still must specify an (empty) pair of double-quotes. Using multiple RESOURCES statements It's sometimes convenient to have FB copy the resources from several different resource files. You can accomplish this by including multiple RESOURCES statements in your program, each specifying a different pathname parameter. If your program includes multiple RESOURCES statements, the second and all subsequent RESOURCES statements should not specify any parameter other than pathname. If your program includes multiple RESOURCES statements, there is the possibility of a "collision" between resources. This happens when a resource in one pathname file has the same type and same ID number as a resource in another pathname file. When this happens, the resource that was encountered later replaces the resource that was encountered earlier, when FB builds your file. You should keep this in mind when deciding in what order to place your RESOURCES statements. New feature in Release 3: If your resource has an ID of 32512-32767, the compiler will renumber it when it sees the conflict. That way, you can refer to it by name and pick it up with GETNAMEDRESOURCE. This is important for those that want to distribute source code with required resources.

Example: You have two resource files in your project.

myRes1.rsrc myRes2.rsrc myRes1.rsrc contains: _"PICT" ID 501 Name "One" _"PICT" ID 502 Name "Two" _"PICT" ID 32512Name "Fred" myRes2.rsrc contains: _"PICT" ID 501 Name "OneOne" _"PICT" ID 502 Name "TwoTwo" _"PICT" ID 32512Name "Barney" Your final application will contain: _"PICT" ID 501 Name "OneOne"<- Note that OneOne replaced One _"PICT" ID 502 Name "TwoTwo"<- Note that TwoTwo replaced Two _"PICT" ID 32512Name "Fred" <- First version of 32512 saved _"PICT" ID 32513Name "Barney"<- Second version of 32512 renumbered Some useful resources

When building an application, FB automatically includes a standard set of resources that applications require. You can enhance your application by also including resources like the following (all of which can be created using ResEdit):

-VERS- "vers" resources with ID's 1 and 2 contain version information which is visible in Finder windows and in the "Get Info" window. See the "Finder Interface" chapter of Inside Macintosh: Macintosh Toolbox Essentials, for more information.

-SIZE- "SIZE" resources with ID's -1, 0 and 1 contain important information about your application's memory size, what kinds of events it can respond to, and more. FB always includes a "SIZE" resource whenever it builds an application, but you may want to override the features in the default "SIZE" resource by providing one of your own. See the "Event Manager" chapter of Inside Macintosh: Macintosh Toolbox Essentials, for more information.

-BNDL, FREF, ICN#- Use these resources to assign special icons to your application and to the documents that your application creates. These resources also determine what kinds of documents can be dragged to you application's icon in the Finder. See the "Finder Interface" chapter of Inside Macintosh: Macintosh Toolbox Essentials, for more information.

See AlsoEdit

CALL <resource>; BUTTON (custom CDEF's); ENTERPROC