Function SetColor() Foundation

Reads or sets current color setting for the text mode.

Syntax
SetColor( [<cColor>] ) --> cColor
Parameters
<cColor>
<cColor> is a character string which contains a comma-separated list of color values. The color values define the system colors for subsequent screen output in the following application areas:
Color values for system colors
Color type Application area
Default output Commands and functions for screen output
Highlighted output GET commands and menu highlighting
Border Screen border (dependent on graphic card)
Background Not supported
Not selected Non-selected GET fields
Each color value contains a pair of colors for the foreground and background color separated by a slash (/) (example: "W/N"). The color values in the list <cColorString> must be separated by commas. Each color value in the list is optional and only the values specified in <cColor> are set. When <cColor> is not specified, no colors are changed.
Return

The return value of SetColor() is a character string which contains a list with the current color values.

Description

The screen function SetColor() reads or resets the list of the automatically supported system colors. The list of the system colors consists of a character string of five color values. They must be separated by commas. A color value consists of a color pair, for the foreground and background color separated with a slash (/). The following letters can be combined for defining color values:

Color table
Color Color screen Monochrome screen
N | Blank space Black Black
B Blue Underscored
G Green White
BG Cyan White
R Red White
RB Magenta White
GR Brown White
W White White
+ Foreground attribute Foreground attribute
N+ Gray White
B+ Pale blue Bold and underscored
G+ Pale green Pale white
BG+ Pale turquoise Pale white
R+ Pale red Pale white
RB+ Pale magenta Pale white
GR+ Yellow Pale white
W+ Pale white Pale white
U Black Underscored
I Inverse Inverse
X Not visible Not visible
* Background attribute Background attribute

The base colors R, G, B, RB, GR, BG, N and W can be modified by an additional color intensity attribute. The plus sign (+) is the attribute for the foreground color and the asterisk (*) raises the intensity of the background color. Both color attributes are recognized regardless of the position they appear in a color value.

The character string with the default colors is: "W/N, N/W, N, N, N/W". The five color values in the list are used in output as follows:

First color value (default output)

The first color value (default) is used with all functions and commands which produce screen output. Those are commands like @...SAY , @...PROMPT and ? or functions like AChoice(), MemoEdit() and QOut().

Second color value (highlighted output)

The second color value (highlighted) is used to highlight the active or selected element in a list or group of elements. This occurs in functions like AChoice() or DbEdit() and in commands like MENU TO or @...GET.

Third color value (screen border)

The third color value determines the color of the screen border. This color can only be set with specific graphic cards.

Fourth color value

The fourth color value is not supported. It can be activated with the function ColorSelect().

Fifth color value (unselected GETs)

The fifth color value determines the color of input fields with the command @..SAY..GET. The active GET field is highlighted (second color value), the other GET fields are displayed with the fifth color value. The output of characters using SAY occurs in the default color (first color value)

The Blink attribute, which is set by the character "*", is supported only in full screen text mode.

Colors for graphics

SetColor() defines colors for the VIO or hybrid mode. When output occurs using graphic functions in the hybrid or GUI mode, the color must be set by GraSetColor(). The function SetColor() has no effect on graphic functions (Gra..()).

Examples
SetColor()
// In the example, the list of color values can be edited in 
// a GET field. The new list is passed to SetColor() and 
// defines the system colors. 

#include "Inkey.ch" 

PROCEDURE Main 
   LOCAL cNewColor, cOldColor := SetColor() 

   DO WHILE LastKey() <> K_ESC 
      CLS 
      cNewColor    := PadR( SetColor(), 40 ) 
      @ 5, 5 SAY "Input colors:" GET cNewColor 
      READ 
      SetColor( Trim( cNewColor ) ) 
   ENDDO 

   SetColor( cOldColor ) 
RETURN 
Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.