KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: 4D View Pro Applying Colors to Formats
PRODUCT: 4D | VERSION: 19 R | PLATFORM: Mac & Win
Published On: May 16, 2022

4D View Pro allows the display format of data to be controlled. For example a data value of 123456 can be displayed as $1234.56 or 123,456 or something else.

The formats can also be colored to apply a specific color to the format. This is done by declaring the color in square brackets before the format.

Below is an example of setting a format to the color Blue:

var $format_t : Text
$format_t:="[blue]0.0"

VP SET NUM VALUE(VP Cell("ViewProArea"; 2; 2); 100; $format_t)
VP SET NUM VALUE(VP Cell("ViewProArea"; 2; 3); 200; $format_t)
VP SET NUM VALUE(VP Cell("ViewProArea"; 2; 4); 300; $format_t)
VP SET NUM VALUE(VP Cell("ViewProArea"; 2; 5); 400; $format_t)
VP SET NUM VALUE(VP Cell("ViewProArea"; 2; 6); 500; $format_t)
VP SET NUM VALUE(VP Cell("ViewProArea"; 2; 7); 600; $format_t)



More complex formattings can be applied, such as the addition of conditionals to apply a specific color. The following example colors the value red if lower than 300, blue if greater than 400 and purple for all values in between:

var $format_t : Text
$format_t:="[red][<300]0.0;[blue][>400]0.0;[purple]0.0"

VP SET NUM VALUE(VP Cell("ViewProArea"; 2; 2); 100; $format_t)
VP SET NUM VALUE(VP Cell("ViewProArea"; 2; 3); 200; $format_t)
VP SET NUM VALUE(VP Cell("ViewProArea"; 2; 4); 300; $format_t)
VP SET NUM VALUE(VP Cell("ViewProArea"; 2; 5); 400; $format_t)
VP SET NUM VALUE(VP Cell("ViewProArea"; 2; 6); 500; $format_t)
VP SET NUM VALUE(VP Cell("ViewProArea"; 2; 7); 600; $format_t)