Reference Guide > W Routines > WwResource Function
  

WwResource Function
Queries, creates, saves, or modifies the widget resource database.
Usage
value = WwResource([resvar])
Input Parameters
resvar — (optional) A string containing a resource variable specification in the resource database.
Returned Value
value — The returned value depends on the input parameter and/or the use of keywords as shown in Value Returned.
 
Table 19-6: Value Returned
Value Returned
Parameter or
Keyword Used
A string containing the value associated with resvar; a null string, if resvar isn’t found; or the default value specified.
resvar, or resvar with Default keyword
An integer value of 1 indicating success, or 0 indicating failure.
Add, Load, or Save keywords
A string containing the resource specification a widget.
Spec keyword
Keywords
Add — A string containing a name: value resource specification to merge into the resource database in the current session. If the resource specification already exists in the application, the Add keyword takes precedence.
Default — (Used only if resvar is specified.) A string specifying a default value for the resource variable in resvar. If resvar doesn’t match anything in the resource database, the default value is returned.
Load — A string specifying the pathname of a resource file to be merged with the existing resource database. If the resource file was specified in the application, the use of the Load keyword takes precedence.
Save — A string specifying the pathname of the resource file in which to save the currently defined resources in the resource database. If the specified file already exists, the contents are overwritten.
Spec — Used to specify a widget ID. The resource variable specification of the widget is returned.
Discussion
WwResource provides direct access to the widget resource database from PV‑WAVE Widgets applications. Resources loaded or added using WwResource are automatically used by subsequently created PV‑WAVE Widgets. The resource specifications merged into the resource database using either the Load or Add keywords supercede existing definitions.
Examples
The following example shows how a resource specification added during a session takes precedence over the existing definition.
myapp*background: red
; The existing resource specification in the database.
; The Add keyword changes the color to blue instead. For the rest 
; of the session, or until it is redefined, the background color
; will be blue.
value = WwResource(ADD='myapp*background: blue')
In the next example, the syntax for using the Load keyword is illustrated.
; This merges the resources found in the specified file with the 
; existing resource database. 
value = WwResource(LOAD='/usr/mydir/myapp/myapp.ad')
This example shows how to request a value associated with a resource name.
; This usage returns the value associated with the resource 
; variable specified. The Default keyword is used to return the
; value 'my label', if the named resource doesn't exist.
value = WwResource('myapp*mybutton.label', $
   Default='my label')
An example for writing all defined resources to a file is:
value = WwResource(SAVE='/usr/mydir/myapp/myapp.newad')
To request the resource variable specification of a particular widget identified by its associated widget ID, use:
value = WwResource(SPEC=widget_id)
See Also
WtResource, WoLoadResources

Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.