Blitz Basic / AmiBlitz allows the use of so-called "Resident" files. These files are chunks of pre-compiled Blitz code, and are usually used to add predefined structs, constants and macros to your code, such as for use with the standard OS libraries.
Adding Resident Files
To add resident files to your source, go to the Compiler Settings window, opened from the Compiler menu of the main Blitz editor. In this window there is an area for Resident files; simply click in the box and add a new line for each resident file you wish to add. In AmiBlitz you should only enter the name of the file itself, AmiBlitz will know where to look for it. Blitz Basic requires the path to the file, which is usually something like BlitzLibs:ExampleFile.res.
Useful Resident Files
- Contains all the structs and constants defined for many key Amiga libraries, including, exec.library, intuition.library, gadtools.library and dos.library.
- Contains definitions for all the internal Blitz object structures.
- Contains all the structs and constants used by the core MUI libraries and classes.
- Contains all the same definitions as MUI.res, in addition to the structs and constants used by many popular 3rd party MUI classes, such as NList.mcc and BetterString.mcc.
- Combines all the contents of AmigaLibs.res, including new definitions for OS3.9, as well as MUI.res, SDSTCP.res, wizard.res and bb2objtypes.res.
Note: Many definitions are provided in multiple resident files. If two resident files are included that both contain the same definition, an error will be given when you try to compile that something is already defined. In this case, you need to remove one of the resident files. To replace it, try to use a resident file that includes all the definitions you need, for example MUI2.res or all.res.
Creating Resident Files
It is possible to create your own resident files, which can be useful for reusing large chunks of code in multiple programs, or to reduce the compilation time of large projects. To create a resident file, you need to create a new source file with all the definitions you require included. This code should not produce any errors when compiled and run. Once you're happy with the code, select Create Resident... from the Compiler menu. This will let you select a filename for the resident file to create - it is recommended to give it the .res extension. Be careful not to overwrite any of the existing resident files accidentally!
Once the file is created, it is then available for use in your programs. Simply enter the filename you created in the Compiler options and you're good to go!