text / background color

Prev Next

Function Names

text color, background color

Description

Standard and portable approach to set the text and background colors on the console. This function memorizes one previous text and background color (and not more) and can be recalled with color name 'previous'.

Call as: procedure

Restrictions

Indirect parameter passing is disabled

OS differences

  • The background color may either fill up parts of the rows where text is printed out, or the entire row.
  • In some consoles, the color specified as 'default' may deviate from the originally visible colors. This is sometimes the case if a console is started with a background color other than black.

Parameter count

0, 1, 3

Parameters

No.TypeDescription
1
input
string Color names

See Console Text and Background Colors for all supported colors and theme color names. Specify all color names in lower-case, including backgroud colors.

Default value: default
Alt. 1
input
string Color as hexadecimal value

The string must begin wiht '#' followed by six hexadecimal digits (0-9, A-F or a-f). The three 2-digit pairs apply to red, green and blue.
Example: '#FF8000' describes orange.

Alt. 1
input
set Color in set

The paramter set provided must contain three numeric values with range between 0 and 255. Values below 0 are raised to 0. Values above 255 are capped to 255. Example: {128,0,255} describes violet.

Alt. 1
input
numeral Red

Specify the red color intensity. Values below 0 are raised to 0. Values above 255 are capped to 255.
Note:All three color parameters for red, green and blue must be specified.

Opt. 2
input
numeral Green

Specify the green color intensity. Values below 0 are raised to 0. Values above 255 are capped to 255.

Opt. 3
input
numeral Blue

Specify the blue color intensity. Values below 0 are raised to 0. Values above 255 are capped to 255.

Exceptions

Invalid color specified

Examples

    savecode
    echo( Default color );
    text color( red ); // Will not show up in red in this documentation
    echo( Red text );
    text color; // Back to default color
    echo( Back to default color );

Output

    Default color
    Red text
    Back to default color

Notes

Highly recommend to set default color before the app is finishing.