bas7advr.hlp (
Topic list)
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 Details
◄Syntax► ◄Details► ◄Example► ◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
The COLOR statement sets the foreground or background colors for the
display.
COLOR [foreground&] [,[background&] [,border&]] Screen mode 0 (text only)
COLOR [foreground&] Screen mode 4
COLOR [foreground&] [,background&] Screen modes 7-10
COLOR [foreground&] Screen modes 12, 13
■ Screen mode 0 (text only) syntax:
COLOR [foreground&] [,background&] [,border&]]
- The foreground color value must be an integer expression between 0
and 31, inclusive. Sixteen colors can be selected with the
integers 0-15. A blinking version of a color is specified by
adding 16 to the color number. For example, a blinking color 7
is equal to 7 + 16, or 23.
- The background color value is an integer expression between 0 and
7, inclusive, and is the color of the background for each text
character. Blinking background colors are not supported.
- The border color, which fills the screen area outside the text
area, is an integer expression between 0 and 15, inclusive. Note
that the border& argument has no effect with the following adapters:
the IBM Enhanced Graphics Adapter (EGA),
the IBM Video Graphics Array adapter (VGA), and
the IBM Multicolor Graphics Array adapter (MCGA).
■ Screen mode 1 syntax:
COLOR [background&] [,palette%]
- The background color value must be an integer expression between
0 and 3, inclusive.
- The palette% argument is an integer expression with an odd or even
value, between 0 and 255, inclusive. An even value makes available
one set of three default foreground colors, and an odd value makes
available a different default set. The following BASIC code defines
the two default sets of colors in terms of EGA PALETTE statements:
' Definition of the even palette-number set.
COLOR ,0 ' In screen mode 1, an even palette number
' is equivalent to next three EGA PALETTE
' statements:
PALETTE 1,2 ' EGA Attribute 1 = color 2 (green)
PALETTE 2,4 ' EGA Attribute 2 = color 4 (red)
PALETTE 3,6 ' EGA Attribute 3 = color 6 (yellow)
' Definition of the odd palette number set
COLOR ,1 ' In screen mode 1, an odd palette-number
' is equivalent to:
PALETTE 1,3 ' EGA Attribute 1 = color 3 (cyan)
PALETTE 2,5 ' EGA Attribute 2 = color 5 (magenta)
PALETTE 3,7 ' EGA Attribute 3 = color 7 (white)
Important: In screen mode 1, a COLOR statement overrides PALETTE
statements that were executed previously.
■ Screen mode 4 syntax:
COLOR [foreground&]
- The argument foreground&, the screen foreground color value, is
an integer expression between 0 and 15, inclusive. This expression
sets the display color associated with color attribute 1 only. The
screen background color is fixed as black.
■ Screen mode 7-10 syntax:
COLOR [foreground&] [,background&]
- The foreground, the line-drawing color, is a color attribute.
- The background, the screen color, is a display color.
■ Screen mode 12-13 syntax:
COLOR [foreground&]
- The foreground, the line drawing color, is a color attribute.
■ The COLOR statement does not determine the range of available
colors. The combination of adapter, display, and the screen mode
determine the color range. See the SCREEN statement for more
details. If you use COLOR statement arguments outside these valid
ranges, BASIC generates the error message, "Illegal function call."
Usage Notes
■ BASIC generates the error message, "Illegal function call" if the
COLOR statement is used in screen modes 2, 3, or 11. Use the
PALETTE statement to set the color in screen mode 11.
■ The foreground can be the same color as the background, making
characters and graphics invisible.
■ The default background color is black for all display hardware
configurations and all screen modes. This background is produced by
the default display color of 0 associated with the background color
attribute of 0.
■ With an EGA, VGA, or MCGA installed, the PALETTE statement gives you
flexibility in assigning different display colors to the attribute
color ranges for the foreground, background, and border colors.
■ In screen modes 12 and 13 you can set the background color by
assigning a color to attribute 0 with a PALETTE statement. For
example, to make the background color 8224 (olive green), you
would use the following PALETTE statement:
PALETTE 0,8224
To make the background color bright red-violet, use:
PALETTE 0,4128831
■ In screen mode 11 you can set both the foreground and background
color by assigning a color to attribute 0 with a PALETTE statement.