### About Resource Statements (OS/2)

Each resource statement consists of one or more keywords, numbers , character strings, constants, or file names. You combine these to define the resource type, identifier, and data.

Note: For more information on resource statements, go to your OS/2 toolkit manual. See Supporting Documentation.

Keywords are words that have a special meaning to the Resource Compiler (RC). In a statement, keywords specify the resource type, the load and memory options, and the beginning and end of nested statements. You can use the RC keywords only as specified in the statement syntax.

Keywords, except for those specifying directives, can be any combination of uppercase and lowercase letters. Note that the curly braces, { and }, are reserved characters. You can use them in place of the BEGIN and END keywords.

Numbers are integers that represent coordinates, dimensions, styles, and other numeric data. You can specify numbers in decimal, octal, or hexadecimal notation:

- Decimal numbers must contain decimal digits but can start with a minus sign (-) when they represent a negative number.
- Hexadecimal numbers must contain hexadecimal digits (uppercase or lowercase) and must start with the characters 0x.
- Octal numbers are similar to hexadecimal numbers, except that a lowercase letter o replaces the x.

The following example shows several numbers represented in decimal, octal, and hexadecimal notation:

DECIMAL | HEXADECIMAL | OCTAL
1 | 0x1 | 0o1
10 | 0xA | 0o12
255 | 0xFF | 0o377
-1 | 0xFFFF | 0o177777
65535 | 0xFFFF | 0o177777

Statements that create controls in dialog windows and menu items in menus require that you specify an identifier for each control or menu item. Statements that create controls also require you to specify coordinates and dimensions.

Identifiers, coordinates, and dimensions are specified using integer values. Each supports a slightly different range of values. Identifiers and coordinates can use either signed or unsigned values ; dimensions only use unsigned values. Coordinates and dimensions can use unsigned values from 0 through 65535; identifiers support unsigned values from 1 through 65535. In addition, identifiers can be character strings as well as numeric values.

The ranges specific to each are listed in the following table.

| Signed Range | Unsigned Range | Character String
--- | --- | --- | ---
Identifiers | -32768 to 32767 | 1 through 65535 | Yes
Coordinates | -32768 to 32767 | 0 through 65535 | No
Dimensions | Not applicable | 0 through 65535 | No

You can also use simple expressions that evaluate to a value in the appropriate range; this enables you to, for example, specify dimensions or coordinates that are relative to those of a corresponding dialog window or menu. A resource identifiers encoded as an expression must resolve to an unsigned integer, not a string.

Character strings represent names, labels, titles, and messages. A character string consists of one or more characters enclosed in double quotation marks . Character values must be in the range 1 through 255. If a double quotation mark (") is required in a string, you must include the double quotation mark twice. The meaning of each character value (that is, the character each value represents) depends on the code page (character set) defined for the resource script file.

The Resource Compiler interprets the backslash (\) as an escape character in character strings. You can include any ASCII character in a character string by specifying either \xdd, where dd is the hexadecimal representation of an ASCII character, or \nnn, where nnn is the octal representation of an ASCII character. If a backslash is required in a string, you must include the backslash twice.

In addition, when character strings are used as resource identifiers additional rules apply:

- They must be enclosed in double quotation marks ("). If a double quotation mark is needed inside the string, it is encoded as two double quotation marks in a row ("").
- They cannot contain any character larger than 0x7F.
- They must be delimited by whitespace, just as an integer ID is.
- Resources whose resource ID is compiled into a 16-bit value in the binary data area, such as MENUITEM with its menu-id field, or HELPSUBITEM with its child-window-id field, cannot use character strings for IDs.
- They can contain an embedded new line character by continuing the string on the following line without closing the string. When the input file represents new line characters as 0x0D+0x0A or by 0x0D+0x0D+0x0A, the string is compiled with the sequence 0x0A to represent the new line character.
- Duplicate string IDs are not permitted for resources of the same type. However, the same string resource identifier can be used to identify resources of different types. When the Resource Compiler is compiling a script file and encounters more than one resource of the same type having the same string ID, it will generate an error message and stop compiling the file. When the Resource Compiler is binding a .res file and encounters more than one resource of the same type with the same string ID, it will generate a warning message and ignore the second resource identifier; only the first resource having the duplicated identifier will be bound to the file.

Constants are names that have been assigned values by using the define directive. A constant can represent a number, a character string, or other data. Most resource statements in a resource script file use constants, and many use the constants defined in the OS/2 header files (for example, os2.h). For this reason, you should always use the include directive to include OS2.H in your resource script file.

File names are OS/2 file names. If the specified file is not in the current directory, you must specify the drive, directory, and file name.

Resource statements have three basic forms:

- Single-line statements
- Multiple-line statements
- Directives

Single-line statements consist of a keyword identifying the resource type , a number or character string that specifies the resource identifier, and a file name specifying the file containing the resource data. For example, this ICON statement defines an icon resource:

    ICON 1 myicon.ico

The icon resource has the icon identifier 1. The file MYICON.ICO contains the icon data. The same example, using a character string is shown below:

    ICON "MyIcon" myicon.ico

Multiple-line statements consist of a keyword identifying the resource type, a number or character string that specifies the resource identifier, and, between the BEGIN and END keywords, additional resource statements that define the resource data. For example, this MENU statement defines a menu resource:

    MENU 1
    BEGIN
          MENUITEM "Alpha", 101
          MENUITEM "Beta",  102
    END

The menu identifier is 1. The menu contains two MENUITEM statements that define the contents of the menu.

In multiple-line statements such as DLGTEMPLATE and WINDOWTEMPLATE, RC allows any level of nested statements. For example, the DLGTEMPLATE and WINDOWTEMPLATE statements typically contain a single DIALOG or FRAME statement. These statements can contain any number of WINDOW and CONTROL statements; the WINDOW and CONTROL statements can contain additional WINDOW and CONTROL statements; and so on. The nested statements let you define controls and other child windows for the dialog boxes and windows. If a nested statement creates a child window or control, the parent and owner of the new window is the window created by the containing statement. (FRAME statements occasionally create frame controls whose parent and owner windows are not the same.)

Directives consist of the reserved character # in the first column of a line, followed by the directive keyword and any additional numbers, character strings, or file names.

Resource Compiler - An Overview
Resource Compiler - Syntax
Resource Script Files
Resource Compiler - An Overview
Resource Compiler - Syntax