40 FOR C=0 TO 63
45 COLOR C,0
50 PRINT C,
55 NEXT C
60 REM —- Get Colors; Print Sample —-
65 COLOR 63,0
70 PRINT “ “
75 INPUT “Input Foreground, Background Numbers:
80 COLOR F,B
85 PRINT “ Sample Text “
90 REM —- Another Sample? —-
95 COLOR 63,0
100 PRINT “ “
105 PRINT “More (Y/N)?”
115 IF A=”Y” OR A=”y” THEN GOTO 65
120 IF A<>”N” AND A<>”n” THEN GOTO 110
• Lines 90-125 do a yes-no check on whether the
user wants to try another sample, then direct program
• Lines 95-105 print the user prompt in white on
• Line 110 gets a keystroke value from the keyboard
and stores it in variable A. Each key is assigned a unique
number value, which can be retrieved by the INKEY
command after that key is pressed. If no key has been
pressed, INKEY returns a value of zero.
• Line 115 checks to see whether the value in
variable A is “Y” or “y.” If it is, program flow jumps to line
65 to get another user input.
• Line 120 checks to see whether A is “N” or “n.” If it
is, program flow continues at line 125. If it is not, program
flow jumps back to line 110 to get another keypress. Note
that this latter branch includes the case where no key has
been pressed (A=0).
• Line 125 marks the formal end of the program
When you quit this program, don’t forget to copy it to
the SD card with SAVE “ COLORS.BAS.” Here’s what’s
going on in this program:
• Lines 10-30 clear the screen and print the title in
white on black.
• Lines 35-55 print each number from 0 to 63 in its
assigned Color BASIC color. The FOR...NEXT loop starts
variable C at a value of 0 on the first loop, then
increments C by 1 on subsequent loops until C equals 63.
• On each iteration of the loop, line 45 changes the
foreground color to the current value of C, while keeping
the background 0 (black).
• Line 50 prints the current value of C in that current
color combination, followed by a Tab character. (The
comma after a PRINT statement tells Color BASIC to
append a horizontal tab instead of a new line to whatever
was just printed.)
• Lines 60-85 prompt the user to input values for
foreground and background colors to sample, and stores
those values in variables F and B.
• Line 75 is the INPUT statement which has the
syntax INPUT “<text prompt>”; <variable1>, <variable2>,...
January 2016 47
FIGURE 2: The right color combinations can dress up your screens.
INPUT is the command to use in your programs when you
need to get an integer value from the user. The text
prompt (if used) is enclosed in quotes, and a semicolon
must separate the prompt from the variables. Multiple
variables can be input if separated by commas. If the
number of variables input by the user differs from the
number expected in the statement, Color BASIC returns a
As you learn Color BASIC, you’ll probably collect
several programs that you run frequently. This program
gives you a “Launchpad” for convenient access to those.
Use the editor to enter and run this code:
• Line 80 sets the user-selected foreground and
• Line 85 prints a text sample in this color set.
10 REM MENU.BAS ***
20 REM —- Print Menu Screen —-
30 COLOR 63,19
50 PRINT “ “: PRINT “ >>> My Amigo Launchpad
<<<“: PRINT “ “