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 Example
◄Example► ◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
' This example illustrates how to use the COLOR statement.
' To try this example:
' 1. Choose New Project from the File menu
' 2. Copy the code example below to the code window
' 3. Press F5 to run the example
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 ' Clear the screen
LOCATE 12, 25: PRINT "Press any key to continue..."
DO
LOOP WHILE INKEY$ = ""
SCREEN 1 ' Set screen to 320 x 200 graphics
COLOR 1, 0 ' Background = 1 (blue)
' Foreground = even palette number
' (red, green, yellow)
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)
COLOR 2, 1 ' Foreground = odd palette (white, magenta,
' cyan)
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
COLOR 7, 0, 0 ' Foreground = 7 (white),
CLS ' Background = 0 (black),
' Border = 0 (black)
SCREEN 0
SCREEN 7
FOR i% = 0 TO 15
COLOR i%
PRINT i%
NEXT i%
SLEEP 5
WIDTH 80
SCREEN 0