Items can be identified by pointers, by the number of the item in the form (i.e., the order they are processed) or by a name that you have specified for a field or memo. There is a family of functions that provide a means of translating from one item identifier to another. The known identifier is specified as a parameter, and the desired identifier is returned. These functions are listed in Table 34.1.
The two most commonly used functions are i_namptr(), which takes the name of the item and returns a pointer to it, and i_numptr(), which takes the processing number of an item and returns a pointer to it.
Table 34.1: Functions to Translate Field Identifiers
| Type | Function Name | Translation |
| int | i_namnum(name_stp, dfmp) | Name to number |
| PTR | i_namptr(name_stp, dfmp) | Name to pointer |
| UCHAR * | i_numnam(item_num, dfmp) | Number to name |
| PTR | i_numptr(item_num, dfmp | Number to pointer |
| UCHAR * | i_ptrnam(itemp) | Pointer to name |
| int | i_ptrnum(itemp, dfmp) | Pointer to number |
Functions that take or return an item number are using the processing order of the fields to determine the item number. Numbering starts at 0. Thus, the first field in processing order has an item number of 0, the second field has an item number of 1, and so on.
We recommend that you use names rather than item numbers to get pointers to your fields. Item numbers will change each time you add, delete or move fields on the form. In your code, if you get a pointer to a field by using an item number, you will need to modify your code each time you modify the form. If you use field names to get pointers to the fields, you avoid this problem. In addition, if you specify meaningful field names, you may make your code easier to understand and maintain.
Caution: For functions that return pointers, you must cast the returned pointer to the appropriate type. For example, the following code fragment gets a pointer to a field named my_field:
|