2.6.2 Adding color specifications to the PRINT statement
I Format I f PRINT l [ f , b]
l ? J
1
variable l ( { ; }
1
variable )
....
.. )
Function
Example
constant
r ,
expression J
or
constant
expression
f PRINT
1 ?
}
[f'
b]
USING
11
format string
11
; variable ( f ; } variable .... )
l '
f .
...
Foreground (character color) specification (a number from 0
to
7)
b
...
. Background color specification (a
number
from 0
to
7)
Adding
the
color specifications to
the
PRINT and PRINT USING statements des-
cribed
on
pages 37 and 38 makes · it possible
to
display characters in a variety
of
colors. In
the
format above, f indicates
the
character foreg'round color, and b indi-
cates
the
character background color.
If
only the foreground color
is
specified, the
current background color is used for display
of
characters; this
is
done
by
specify-
ing
the
foreground color, followed
by
a comma.
If
only
the
background color
is
specified,
the
current foreground color
is
used for
display
of
characters; in this case, a comma must precede the background color
specification.
(Example 1)
PRI
NT C6 .
5)
11
ABCDE
11
· •
•••
Displays the letters "ABCDE" in
P R I NT
C.
4)
11
FGH I 0 u
yellow against a background
of
light
blue.
. . . . Displays the letters
"FGHIJ"
in yellow
against a background
of
green .
P R I N T C
7,
)
11
VW
X Y Z
''
. . . . Displays the
letter
"VWXYZ" in green
against a background
of
white.
(Example 2) Let's
try
adding color to the automobile race program shown
on
page
46.
1 0 ·
PR
I NT C.
1)
11
[!]
11
2 0 Q
=I
NT C5 * RND C1
))
+
2:X
=3
3*
RND C1 )
3 0
FOR
A=1
TO
5
4 0
READ
M$
5 0
PRIN
T
TAB
C0)
;
11
+
11
;
TAB
CX)
6 0
PR
I NT
CO.
1 )
M$
7 0
PRINT
(
7'
1 )
TAB
C37) ;
11
+
11
8 0
NEXT A
9 0 Y
=1
0*
RND C1 )
1
00
FOR
A
=1
TO Y
11
0
PRINT
TAB
C0)
11
+
11
;
12
0
PR
I NT
TAB
C
37
)
:
11
+
11
NE XT
13
0
REST
ORE : G
OTO
20
14
0
DATA "
~
[)
liiiJ
"
"
~
IS:9
1::al6
:::
n~
"
15
0
DATA"
l::all::all::al
"
"
~l::all::all::al~
"
16
0
DATA "
["11111.1!1"']
With ordinary PRINT statements (those
without
color specifications), the fore-
ground and background colors used for character display are those which have been
specified
with the latest COLOR statement.
------------------
----
------------
--
----
--------
--
-----------------81