| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Extracts a color value from a color string.
HB_ColorIndex( <cColorString>, <nColorIndex> ) --> cColorValue
The function returns the color value at position <nPos> in the passed color string as a character string. If <cColorString> has less than <nPos>+1 colors, the return value is a null string ("").
The function HB_ColorIndex() extracts a color value from <cColorString>. Constants from the COLOR.CH file can be used to address a specific color value:
#define constants for HB_ColorIndex()
| Constant | Value | Description |
|---|---|---|
| CLR_STANDARD | 0 | All screen output commands and functions |
| CLR_ENHANCED | 1 | GETs and selection highlights |
| CLR_BORDER | 2 | Screen border (not supported on EGA and VGA monitors) |
| CLR_BACKGROUND | 3 | Not supported |
| CLR_UNSELECTED | 4 | Unselected GETs |
| See also: | ColorSelect(), GetClrPair(), SetClrPair(), SetColor() |
| Category: | Screen functions , xHarbour extensions |
| Header: | color.ch |
| Source: | rtl\colorind.c |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The example demonstrates return values of HB_ColorIndex()
#include "Color.ch"
PROCEDURE Main
LOCAL cColor := "N/W,W+/N,W+/W,W+/B,GR+/B"
SetColor( cColor )
? HB_ColorIndex( cColor, CLR_STANDARD ) // result: N/W
? HB_ColorIndex( cColor, CLR_ENHANCED ) // result: W+/N
? HB_ColorIndex( cColor, CLR_BORDER ) // result: W+/W
? HB_ColorIndex( cColor, CLR_BACKGROUND ) // result: W+/B
? HB_ColorIndex( cColor, CLR_UNSELECTED ) // result: GR+/B
RETURN
http://www.xHarbour.com