Chapter 1 of 12
Make the CoCo answer
Your flight computer is awake. Before you let it steer, make it show you how it thinks. You can ask three questions with almost the same keys and get three different answers.
Try the keyboard at OK
Start with Disk BASIC in a practice session. If you have a program in the CoCo that you want to keep, save it before using the numbered lines below. Click inside the CoCo display. When you see OK, type each of these lines and press Return after each one. Predict the next answer before you press the key.
PRINT 2+3*4
PRINT (2+3)*4
PRINT "2+3*4"
The first answer is 14. The star means multiply. BASIC multiplies 3 by 4 first, then adds 2. The second answer is 20. Parentheses tell BASIC to finish the addition first. The third answer is 2+3*4, right down to the star. Quotation marks tell BASIC to take those five characters as text. Programmers call a piece of text a string.
An instruction you type this way is an immediate command. BASIC carries it out as soon as you press Return. Use the Mac keyboard as the CoCo keyboard while the display has focus. If typing moves a Mac control instead, click the CoCo display again.
Give tomorrow’s pilot a message
At the practice prompt, enter NEW to clear the old listing from guest memory. Type these two lines, pressing Return after each.
20 PRINT "PLANET EXPLORER"
30 PRINT "1 EARTH 2 MARS"
What happened to the menu? You saw your typing, then a new input line. The numbers tell BASIC to store the instructions. Type LIST to see what it kept. Now type RUN. This time the CoCo prints the title, prints the two choices, and says OK. You can type RUN again any time you want that menu back.
Slip a line between the two you already have. Enter 25 PRINT "WELCOME ABOARD", then RUN. The welcome appears between the title and the destinations. BASIC follows the numbers, even though you typed line 25 last. Enter just 25 and press Return. Type LIST again. Lines 20 and 30 remain. Entering a bare line number at the guest prompt deletes that line. An entire replacement line with the same number changes it. This is why you often see gaps between BASIC line numbers.
Keep a Mac copy
Open Develop → BASIC Development…. Choose Read from CoCo. If the editor is holding work you want, use its save option first. Look for the same two numbered lines you saw with LIST. Choose Save As… in the editor’s file actions and give your Mac source a name such as Menu.bas.
| Place | What lives there | How to find it |
|---|---|---|
| CoCo RAM | Instructions the guest BASIC interpreter can run, plus working values while it runs | LIST at the guest prompt shows the instructions. |
| Mac editor | Editable text, including any changes you have typed since the last transfer | Read from CoCo pulls the current guest listing into the editor. Save keeps the text in a Mac file. |
Load into CoCo sends the editor’s listing to guest RAM and leaves BASIC ready. The editor’s Run sends it and starts it. Either operation can replace the program in guest memory; read the replacement prompt before choosing. The Run control in the main emulator window resumes the entire machine after a pause. Use the editor’s Run when you want the BASIC listing to start at the beginning.
In the next lesson, you’ll add the missing part of the menu: the CoCo will wait for a passenger to choose a planet.