The following example defines some standard departmental colors from RGB values stored in a table:

function setCorporateColors(cDeptName

local q, r 

   q = new Query("select * from COLORSCHEME"  

   r = q.rowset 

   if r.applyLocate("DEPTNAME = '" + cDeptName + "'") 

      private rgbValue // Use private var for &macro 

      rgbValue = r.fields[ "BACKGROUND" ].value 

      define color DEPT_BG &rgbValue 

      rgbValue = r.fields[ "LOGO" ].value 

      define color DEPT_LOGO &rgbValue 

      rgvValue = r.fields[ "TEXT" ].value 

      define color DEPT_TEXT &rgbValue 

   endif 

The function takes the department name as a parameter. If that department has a listing in the table, RGB values like "115,180,40" are read from the table and used for different standard colors, such as the background and text color. &macro substitution is used to convert the value strings into the literal numeric values, separated by commas, that are expected by the DEFINE COLOR command.

Presumably, default departmental colors have already been defined so that if no match is found, the color names can be used.