Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
COLOR Statement Programming Example
◄Example► ◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
'These examples use COLOR statements to show their effects in various screen
'modes.
SCREEN 0 'Text mode only.
'Foreground = 1 (blue), background = 2 (green), border = 3 (cyan).
'EGA and VGA boards do not support the border argument.
COLOR 1, 2, 3
CLS
LOCATE 12, 25: PRINT "Press any key to continue..."
DO
LOOP WHILE INKEY$ = ""
SCREEN 1 'Set screen to 320 x 200 graphics.
'Background = 1 (blue), foreground = even palette number (red, green,
'yellow).
COLOR 1, 0
LINE (20, 20)-(300, 180), 3, B 'Draw a brown box.
LOCATE 12, 7: PRINT "Press any key to continue..."
DO
LOOP WHILE INKEY$ = ""
'Background = 2 (green), foreground = odd palette (white, magenta, cyan).
COLOR 2, 1
LINE (20, 20)-(300, 180), 3, B 'Draw a bright white box.
LOCATE 12, 7: PRINT "Press any key to continue..."
DO
LOOP WHILE INKEY$ = ""
SCREEN 0 'Set screen to text mode.
'Foreground = 7 (white), background = 0 (black), border = 0 (black).
COLOR 7, 0, 0
CLS
END