Converting Resource Values

Another convenient feature of CLUE resource management is automatic resource type conversion. Often the type of value specified by the user in the resource database is not the data type actually used by the program. For example, a user might identify a font by a string such as ``helvetica,'' but the program must convert this name into a CLX font object before text is displayed. Another example is color: where a user might specify ``red,'' a program must somehow determine a colormap and pixel value that will yield this hue.

CLUE automatically converts user values out of the user's resource database into the correct target data type (as specified in the :resources option of a defcontact form). This is done by calling the convert function. For example:

(setf color (convert         ; Convert a resource...
              a-blinker      ; ...for a blinker...            
              "red"          ; ...from a string value...              
              'pixel))       ; ...to a pixel target type.

CLUE defines a number of convert methods for various combinations of source and target data types. Contact programmers can extend this mechanism by defining their own special convert methods.