COLOR Phrase

{COLOR } IS color-val
{COLOUR}
  1. The COLOR phrase provides an alternate method for setting video attributes. It also allows the specification of colors for screen fields and controls.
  2. color-val can be set to different numeric values to express various combinations of colors and video attributes. You may make combinations by adding the appropriate values together. The following color values are accepted:
    Color Foreground Background
    Black 1 32
    Blue 2 64
    Green 3 96
    Cyan 4 128
    Red 5 160
    Magenta 6 192
    Brown 7 224
    White 8 256

    You may specify other video attributes by adding the following values:

    Reverse video 1024
    Low intensity 2048
    High intensity 4096
    Underline 8192
    Blink 16384
    Protected 32768
    Background low-intensity 65536
    Background high-intensity 131072

    You may also specify high intensity by adding "8" to the foreground color value.

  3. Only one foreground color and one background color may be specified. High intensity and low intensity may not both be specified. If neither is specified, the default intensity is used. If either the foreground or background color value is missing, then the corresponding default for the current subwindow is used. However, some control types follow different rules for selecting the default color. These rules are described in Control Types Reference.

    When a control is assigned a non-zero foreground or background color, that component will no longer revert to the default when assigned the value 0 (zero). Instead, assigning 0 simply reassigns the current color. The runtime uses this behavior to preserve one component (foreground or background) when changing the other.

  4. Other video attribute clauses (such as the REVERSED clause) may be specified along with the COLOR clause. The effects of all such clauses are used together. If any conflict exists, the COLOR clause takes precedence.
  5. Reverse video exchanges the foreground and background colors.
  6. If a terminal does not support color, then all non-black colors are mapped to white at runtime. If this results in a white-on-white combination, then the background color is set to black. However, if you explicitly specify identical foreground and background colors, then the characters will be invisible.
  7. The Protected attribute applies to only Format 1 Screen Section entries. Any input or update field that has the Protected attribute set for it is ignored during an ACCEPT statement. This enables you to selectively allow entry of certain data fields. The Protected attribute does not affect the behavior of the DISPLAY statement.
  8. The Protected attribute cannot be applied with the MODIFY statement and the COLOR phrase. For example, the following will not set the field to "Protected":
    01   my-field, ENTRY-FIELD, LINE 1, COL 1.
    
    MODIFY my-field, COLOR=32768

    Instead, use a color variable to accomplish the effect, as in:

    01  my-color   PIC 9(5) VALUE ZERO.
    
    01  my-field, ENTRY-FIELD, LINE 1, COL 1, 
           COLOR my-color.
    
    ADD 32768 TO my-color.
  9. When the COLOR phrase is used with controls, each control type determines the allowable set of colors. Each control class defines its own method of assigning default colors. Note that many host systems limit the ability to define a control's colors. The colors used will be as close to the requested colors as the host system allows.