Resources and Strings
GUI application management is aided by using resource and string files. Resource and string files provide an easy method for customizing and internationalizing PV-WAVE applications. This is accomplished by isolating the dynamic aspects of the application in files which are distinct from the code. Thus, the ability to customize becomes a process of translating a few files in tight proximity rather than many individual lines of code spread throughout the application. Resources are distinguished from strings because they describe the appearance or behavior of widgets, while strings are not specifically widget-related.
Resources
Using resources to describe the application’s appearance enables you to customize Wave Widgets or VDA Tools to your applications, without modify the code. In addition, PV-WAVE is designed to allow multiple resource files per application, so the various resources can be loaded as needed rather than loading everything at the application startup.
A resource definition as it appears in a resource file is really a name/value pair. The name, the first part of the pair, describes the widget to which the resource value is applied. For instance, the following resource name/value pair:
myapp.save_button.labelString: Save
essentially says,
Within the application myapp there is a button named save_button. Set the label on that button to the string "Save".
Resource files are a collection of many resource name/value definitions, such as the previous example, that are loaded as needed prior to creating the widgets they describe.
Resource names are constructed by traversing the widget tree to the target widget instance. The precise path required depends on the design of your particular application. Widgets are named explicitly using specific keywords found in the Wave Widget commands. The Ww layer routines you use to create a widget have one or more of the following keywords: Name, Layout_Name or Shell_Name. These keywords use one or more resource datatype strings to create widgets with the specified names.
Resources loaded using the PV-WAVE resource-loading routines (see "Resources and Strings in PV-WAVE Applications") are merged into the standard system resource database which is used when widgets are created. As a result, no special commands are necessary to assign the resource values to a widget; instead, this is done automatically when the widget is created.
 
note
You must name the resource so that it matches the name of the widget it modifies.
Many rules exist regarding the syntax of resource definitions. For a complete description of resource bindings and precedence rules consult the chapter on Resource Management in X Toolkit Intrinsics Programming Manual, Volume 4, O’Reilly & Associates, Inc.
Strings
Strings are similar to resources in that they allow you to customize your PV-WAVE applications without having to modify the code. The difference is that strings do not directly describe the appearance or behavior of a widget like resources do. Strings are often used for error messages or to construct labels that are completed during the execution of the application.
Suppose the application opens a user-specified file as part of its commands. The application should be able to display an error message in the event the named file doesn’t exist when the application is run. Since it’s desirable to specifically name the file as part of the message, the message construction should consist of a static string (such as 'Cannot open the file') and a dynamic file name. String files are used for just this purpose.
The string file syntax is very similar to that of a resource file; it’s comprised of a name/value pair. Unlike resource definitions, however, the name portion of the string definition is a single identifying string rather than a hierarchical definition. For instance, the following string definition:
myapp_open_error: Cannot open the file
defines a string suitable for the example.
Strings loaded using PV-WAVE string-manipulating routines are loaded into a common string database. The database is distinct from the resource database, so no interaction between strings and resources is possible.
 
note
Special care should be taken to ensure that the name used in the string definition is unique among all other strings loaded by any application.
A good way to ensure your string names are unique is to add the application name to the front of the string name. In this way, the possibility of conflicting definitions exists only if two applications have the same name.