About Resource Statements

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.

Keywords are words that have a special meaning to the Resource Compiler. 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:

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

┌────────────────────┬────────────────────┬────────────────────┐│DECIMAL             │OCTAL               │HEXADECIMAL         │
├────────────────────┼────────────────────┼────────────────────┤
│1                   │0o1                 │0x1                 │
├────────────────────┼────────────────────┼────────────────────┤
│10                  │0o12                │0xA                 │
├────────────────────┼────────────────────┼────────────────────┤
│255                 │0o377               │0xFF                │
├────────────────────┼────────────────────┼────────────────────┤
│-1                  │0o177777            │0xFFFF              │
├────────────────────┼────────────────────┼────────────────────┤
│65535               │0o177777            │0xFFFF              │
└────────────────────┴────────────────────┴────────────────────┘

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 │Strings   │
├───────────────┼────────────────────┼───────────────┼──────────┤
│Identifiers    │-32768 through 32767│1 through 65535│Yes       │
├───────────────┼────────────────────┼───────────────┼──────────┤
│Coordinates    │-32768 through 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:

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 consist of a keyword identifying the resource type, a number or character string which 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 character strings for identifiers is shown below:

  ICON "MyIcon" myicon.ico

Multiple-line statements consist of a keyword identifying the resource type, a number or character string which 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.


[Back: Defining Constants]
[Next: Binary Resource Files]