#RESOURCE metastatement

Purpose

Embed a PowerBASIC Resource (.PBR) file into the executable file.

Syntax

#RESOURCE "filespec"

Remarks

This metastatement is used to include (embed) a PowerBASIC resource (.PBR) file into your compiled program.

filespec

If filespec does not include a path, the compiler scans the search path the #RESOURCE file before checking the current (default) directory.  For the IDE, the search path can be set in the Compiler Preferences tab in the Options dialog.

PowerBASIC metastatements support Long File Names (LFNs).

 

The search path can also be specified when using the Resource Compiler (RC.EXE) from the command-line by using the /i (INCLUDE) option -- see RC.HLP for more information.

To create a .PBR file, you must first create a resource script (.RC) which contains resource commands.  A typical resource file to specify an Icon consists of just one line of text:

ICON1 ICON MYICON.ICO

This line of text would be saved as a .RC file, and then compiled into a .RES file with a suitable resource compiler.  PowerBASIC resource files can be compiled directly from the PowerBASIC IDE.  They can also be created using a resource compiler (such as the Microsoft™ Resource Compiler, RC.EXE) which converts a resource script (.RC) file into a binary resource (.RES) file, which is then processed by the PBRES.EXE utility to create a .PBR file. 

Resource files can contain bitmaps, string data, custom binary data, version information, dialogs and a whole lot more.  To create more complex resource files, a Resource Editor is highly recommended.  PowerBASIC's PB/Win compiler includes a copy of the Microsoft Dialog Editor (DLGEDIT.EXE), and the Microsoft Resource Compiler (RC.EXE).

The PowerBASIC IDE can be used to compile a Resource Script (.RC file) into PowerBASIC resource file format (a .PBR file) without resorting to using command-line tools to compile resource files.  For additional information on creating resource files, please review the Resource Files chapter.

Restrictions

PowerBASIC does not permit more than one #RESOURCE statement per module.  If you need more than one, the usual way to accomplish this is to create a separate DLL for each additional resource file (using PowerBASIC's PB/Win compiler).

Note: If you are adding an icon resource to a Console mode application, please note that Windows 95's "Windows Explorer" will not display icons of console applications in file lists.  This behavior was corrected in Windows 98, and later editions of Windows.

See also

Resource Files

Example

#RESOURCE "HELLO.PBR"