Article ID: 29943 - Last Review: November 21, 2006 - Revision: 1.2 SCREEN Function Gives COLOR Attribute; Foreground, BackgroundThis article was previously published under Q29943 On This PageSUMMARY
When using text mode (using the SCREEN statement with mode 0), the
SCREEN function can return the color attribute of a character on the
screen. If the SCREEN function is invoked at a location where a
character is printed, the color attribute returned is a combination of
the foreground and background colors. However, on a graphics screen
mode (a SCREEN mode other than 0), the SCREEN function always returns
zero.
If the character is not blinking (that is, the high-order, eighth bit is off), the foreground color can be obtained by taking the color attribute MOD 16, and the background color can be obtained by dividing the color attribute by 16. If the character is blinking, just turn off the eighth bit in the attribute byte before this calculation. For example: MORE INFORMATION
The following is a bitmap of the attribute returned by the SCREEN
function:
BIT -> 7 6 5 4 3 2 1 0
_________________________________________________
| 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 |
-------------------------------------------------
^ ^ ^ ^ ^ ^ ^ ^
| | | | | | | |
Blinking -- ------------- | -------------
| Intensity -- |
Background Color -- -- Foreground Color
Code ExampleAPPLIES TO
| Article Translations
|

Back to the top
