core

### Changing a String's Text Color

Using the RGB Function

The Reporting expression language lets you use a RGB function to define an RGB (Red Green Blue) color value and apply it to a string of characters in expression text. This function takes four parameters, a string parameter, followed by comma separated RGB parameters, like this:

=RGB(string,R,G,B)

If you type this function in the Cell Expression box (or cell) of the GridControlObject, click OK, and then click outside of the object, PC-DMIS evaluates the expression and gives the text the specified color value.

Cell Expression box showing the RGB expression

For example, if you type this expression into a cell,

=RGB("Blue Text",0,0,255) + RGB(" Black Text",0,0,0) + RGB(" Yellow Text",255,255,0)

then the words would look like this in a template editor:

Displaying a Dimension Color with RGB

For the second parameter in the RGB function, if you use a value that exceeds 255, PC-DMIS interprets that parameter as a COLORREF value instead of a standard 0 - 255 RGB value. In this case, PC-DMIS ignores the second and third parameters (although you do need to include them). You can use this approach to return the color of the dimension's axis if you use the DIM_RPT_TOLERANCECOLOR1 data type.

For example, suppose you use this expression in a cell of a GridControlObject:

=RGB(NOMINAL:N,DIM_RPT_TOLERANCECOLOR1:N,0,0)

This grabs the nominal value of the current axis undergoing evaluation and sets the color to that axis's dimension color.

The :N behaves as a variable that holds the current dimension axis index so that the expression returns the color value of each axis.

You can also specify a specific axis. For example, suppose you have a dimension with three axes, X, Y, and Z.

- DIM_RPT_TOLERANCECOLOR1:1 returns the color value for the first axis, X.

- DIM_RPT_TOLERANCECOLOR1:2 returns the color value for the second axis Y.

- DIM_RPT_TOLERANCECOLOR1:3 returns the color value for the third axis Z.

If you do not define the optional index (:N), it returns the color of the dimension itself.

Using the Color Function

The Color function takes two parameters. The first, a color parameter, is actually a number that represents one of the principle Edit window colors. The second, is the string value to which PC-DMIS applies the color.

=COLOR(1, "My Text")

The first parameter is a value of 1 to 4 and passes the Edit window color that associated with the following:

1 passes the Marked Color

2 passes the Unmarked Color

3 passes the Step Mode Color

4 passes the Error Color

These colors are defined in the Edit window's Color Editor dialog box (Edit | Preferences | Edit Window Colors). For information on this dialog box, see "Defining Edit Window Colors" in "Setting Your Preferences" for information.