Chapter 2 of 7
Give one instruction
You’ve asked BASIC to show words you supplied. Now give it a plus sign. Can you make the sign disappear in one answer and show up in the next?
Try it on your CoCo
At the OK prompt, click the CoCo screen or press Option-Command-K. Type this line. Guess what will appear beneath it, then press Return.
PRINT 2+3
Check your prediction
The answer is 5. Look closely and you’ll see a space before the digit. BASIC leaves room for the sign when it prints a positive number.
Here are the same numbers and the same plus sign. This time, type a double quotation mark on each side of them. Make your prediction, then press Return.
PRINT "2+3"
You should see 2+3. Inside the quotes, each character is a piece of text to show. The plus sign gets a spot on the screen along with the two digits. The quote marks themselves have done their job by telling BASIC where the text begins and ends.
Put the question and answer on one line
There are two plus signs in this next instruction. Point to the one you think will reach the screen. Type the line at the prompt and press Return.
PRINT "2+3=";2+3
2+3= 5
Read it from left to right. First comes the text between the quotes, right through the equals sign. The semicolon tells PRINT to carry straight on with the next item. Outside the quotes, the second plus sign tells BASIC to add. The result is a number, so it gets that space in front of it.
How did the CoCo know the word PRINT? Its ROM, short for read-only memory, holds a program called the BASIC interpreter. The interpreter recognizes BASIC words and symbols. A chip called the CPU, or central processing unit, carries out the interpreter’s instructions. Your two plus signs gave it two different jobs on the very same line.
Where to go next
So far, pressing Return has meant “do this now.” In chapter 3 you’ll give the CoCo a message it can repeat on demand.
Curious about fitting more letters across the screen? Pick a planet uses a 40-column CoCo 3 display. You can come back to the Moon Base story whenever you like.
Tandy Corporation. Tandy Color Computer 3 BASIC Quick Reference Guide. 1986. Commands, pp. 2–17, particularly PRINT.