Combee on Palm OS

Thursday, 9 December 2004  8:25 AM

A few days ago, I posted about how the Palm OS Resource Editor in PODS 1.1 supports generating header files.  On the palm-dev-forum, Eric Cloninger, PalmSource's resource tools expert, posted some tips on how to specify the template used to generate identifiers.

The resource tools guide should have this information in it, but I see that it hasn't been made public yet. The values you can use for the template are

%RT Defines the resource type, such as Form, Alert, Bitmap, etc. This item will always have a value.

%RI Defines the numeric resource identifier as a string. This item will always have a value.

%RC Defines the resource comment if it is available. If the comment has characters that are not valid for a C/C++ header definition, they are stripped from the string prior to being used. This item has a value if and only if the user has provided one in the source file.

%RE Text of the resource. In the case of strings and other resources that have a textual component, this value is defined. For resources that do not have textual components or for resources that have many textual items, such as bitmaps and string lists, this value is not defined.

%RL Defines the resource title if one exists. Most likely use is for Form and Alert resources.

%OT The object type, such as PushButton, MenuItem, and StringListItem.

%OI The object ID if one is relevant. Most likely use is in Forms.

%OC The object Comment if it is applicable.

%OE The object text if it is applicable.

%OX The object index, starting at 0, in the larger group.

The ? Operator, like the C operator, tests for empty values and then uses the second value if true and the third if false. This attempts to make unique identifiers from all the resources and objects. If you aren't consistent in your use of comments, you could end up generating bad identifiers or duplicates. Either use them well or don't use them at all. The comments need to be in Latin-1.

Eric also provides a workaround for a bug in the default templates used in the current resource editor where it uses the label text, rather than the label comment when generating its identifier:

In the files panel, select the XML source file. In the properties panel for that file, insert the following string into the Variable template field.

k[?%RC,%RC%RT,%RT%RI][?%OC,%OC%OT,%OE%OT]

What this says, in human terms, is to always start with a lower case 'k'. Then look (?%RC) at the resource comment. If one exists, use it, followed by the resource type (%RT). Otherwise, use the resource type followed by the resource ID (%RT%RI). For forms or other things that have sub items, look at the object comment (?%OC). If one exists, use it followed by the object type (%OC%OT). Otherwise, use the object text followed by the object type (%OE%OT).