Atari PILOT for Beginners: Type, Accept, Match and Turtle Graphics
PILOT (Programmed Inquiry, Learning Or Teaching) was created by Dr. John Starkweather at the University of California, San Francisco, so that teachers could write lessons for their students. Dr. Dean Brown's work at Stanford Research Institute in the late 1960s and early 1970s showed that children could program in it too. Atari PILOT, a cartridge implemented by Harry Stewart (program copyright 1980, manuals 1981), kept PILOT's question-and-answer core and added two big extras: turtle graphics borrowed from Logo, and sound. It's a gentle first language, and it still makes quick, friendly quiz and drawing programs.
What you'll learn: the core commands (T:, A:, M:, J:, U:, E:, C:, R:), conditions, the executive commands (AUTO, LIST, REN, SAVE, LOAD), turtle graphics with GR:, music with SO: and PA:, and how to save your work.
What you need: the Atari PILOT cartridge (or its image in an emulator) and any Atari 400/800/XL/XE. A disk drive or program recorder lets you save programs.
1. How a PILOT line looks
Every PILOT statement is a command of one or two letters followed by a colon, and then its text. Give a line a number (0–9999) and it becomes part of the program. Leave the number off and it runs immediately, like a calculator. Labels start with *, mark a place in the program, and can be up to 254 characters long.
There are two kinds of variables:
- String variables:
$plus letters and digits, such as$NAMEor$FOOD9. Each holds up to 254 characters. - Numeric variables:
#plus a single letter,#Ato#Z. That's 26 in all, holding whole numbers from −32768 to 32767.
PILOT arithmetic is integer only: +, -, *, / and \ (remainder). So 5/2 gives 2.
2. The core commands
T: (Type) prints the rest of the line, and variables inside the text are replaced with their values. An empty T: prints a blank line. End the text with a backslash (\) and the cursor stays on the same line, which is perfect for questions.
A: (Accept) reads a line from the keyboard. A:$NAME stores it in a string variable, A:#X in a number, and a bare A: keeps the answer just for the next match.
M: (Match) compares the last answer with a comma-separated list and sets a Y (yes) or N (no) flag. Matching finds the item anywhere in the answer. In Atari's own dragon example, M:PEOPLE,PRIN,KNI,CAKE matches the reply LITTLE PRINCESSES.
The flag then steers any command with Y or N added: TY: types only if there was a match, TN: only if there wasn't. Likewise JY:/JN: and UY:/UN:.
J: (Jump) goes to a label: J:*START. PILOT programs jump to labels, never to line numbers.
U: (Use) calls a label like a subroutine. E: (End) ends the program, or, at the end of a used module, returns to the line after the U:. Every module you U: must finish with E:.
C: (Compute) does arithmetic: C:#X=#X+1. C:#X=? gives a random number, and C:#X=?\6 a number from 0 to 5. R: is a remark.
JM: jumps by match position. After M:R,Y,B, the line JM:*RED,*YELLOW,*BLUE goes to the label matching whichever item was found.
A first program, from Atari PILOT Activities and Games (Reston, 1983):
10 T:HOW ARE YOU FEELING?
20 A:
30 M:GOOD,FINE,OK,WONDERFUL
40 TY:GLAD TO HEAR IT
50 TN:HOPE YOU FEEL BETTER TOMORROW
3. Conditions and loops
Any command can carry a numeric condition in parentheses, placed before the colon. The comparisons are =, <, >, <=, >= and <>. The command only runs if the condition is true:
10 C:#X=1
20 *GROWTH
30 C:#X=#X+1
35 T:#X
40 J(#X<20):*GROWTH
That counts from 2 to 20. Conditions work on T:, A:, C:, U:, GR:, SO: and the rest, so T(#A=#B):RIGHT! types only when the two match.
To use the computer's memory directly there is @B, "at byte": C:@B710=0 stores 0 in location 710 (the text background colour, so the screen turns black), and C:#V=@B82 reads location 82 (the left margin). This is PILOT's equivalent of POKE and PEEK.
4. The editor and executive commands
Executive commands act on the whole program and are typed without line numbers:
| Command | What it does |
|---|---|
AUTO |
numbers lines for you as you type (AUTO 100,20 starts at 100, steps by 20). The screen turns yellow while AUTO is on |
LIST |
lists the program; LIST 40,80 a range, LIST 50 one line |
REN |
renumbers by tens from 10; REN 100,5 starts at 100 in steps of 5 |
RUN |
runs the program |
NEW |
erases the program |
VNEW: |
clears variables only (VNEW:$ strings, VNEW:# numbers) |
DUMP |
lists every string variable and its contents |
DOS |
goes to the DOS menu |
You edit lines with the Atari's normal screen editor: move the cursor onto a listed line, change it and press RETURN.
5. Turtle graphics
All drawing commands start with GR:. The graphics screen is a grid with (0,0) in the middle: x runs from −79 to +79 and y from −47 to +47. A four-line text window covers the bottom, so the visible drawing area ends at y = −31. The turtle starts at 0,0 facing 0 degrees (straight up) with the yellow pen.
| Command | Action |
|---|---|
GR:DRAW n / GR:GO n |
move n units forward, drawing / without drawing |
GR:TURN n / GR:TURNTO n |
turn n degrees clockwise (negative = anticlockwise) / face heading n |
GR:DRAWTO x,y / GR:GOTO x,y |
move to a point, drawing / without drawing |
GR:FILL n / GR:FILLTO x,y |
draw while filling the area to the turtle's right up to the next line |
GR:PEN RED (or YELLOW, BLUE, ERASE, UP) |
choose a pen |
GR:CLEAR |
clear the graphics screen |
GR:QUIT |
go back to the full text screen |
Several commands can share one line, separated by semicolons. A count before parentheses repeats them, so a square is:
10 GR:CLEAR;4(TURN 90;DRAW 30)
and GR:36(DRAW 5;TURN 10) draws a circle as a 36-sided polygon. Type graphics commands without a line number to sketch directly; add a line number to anything you like and it becomes part of your program.
6. Sound and pauses
SO: plays notes numbered 1 to 31: 1 is the C an octave below middle C, 13 is middle C, and 31 is the F sharp an octave above. SO:0 stops the sound. Up to four notes separated by commas make a chord: SO:13,17,20. PA:n pauses for n sixtieths of a second, so PA:64 is a quarter note in the tempo the Reston book uses and PA:60 is one second.
PILOT's SO: only sets pitch: tone and volume are fixed. For other sounds you can write the POKEY registers directly, for example C:@B53760=100 and C:@B53761=8+64 (pitch 100, distortion 4, volume 8). Ken Harms showed how in Antic, February 1983.
7. Putting it together
This program asks for a number of sides, draws that polygon, plays a note and offers another go. Every command in it is documented above:
10 R:POLYGON MAKER
20 *ASK
30 T:HOW MANY SIDES (3-12)? \
40 A:#S
50 J(#S<3):*ASK
60 J(#S>12):*ASK
70 C:#A=360/#S
80 C:#L=120/#S
90 GR:CLEAR;GOTO 0,-20;TURNTO 0
100 GR:#S(DRAW #L;TURN #A)
110 SO:13
120 PA:30
130 SO:0
140 T:ANOTHER ONE? \
150 A:
160 M:Y
170 JY:*ASK
180 E:
Line 80 shrinks the side as the count grows, so every shape stays on screen. Because PILOT divides in whole numbers, 7 sides give a 51-degree turn and the heptagon doesn't quite close: a nice talking point about integer arithmetic. Line 160 accepts any answer containing a Y.
8. Saving and loading
| Task | Command |
|---|---|
| Save to cassette | SAVE C: (press PLAY and RECORD together at the two beeps, then RETURN) |
| Save to disk | SAVE D:COLORS.V03 |
| Save part of a program | SAVE D:MODULE1 10,50 or SAVE C:10,50 |
| Print a listing | SAVE P: (or SAVE P:20,50) |
| Load | LOAD C: or LOAD D:COLORS.PLT |
Note that there are no quotation marks around the device and filename, unlike BASIC. Cassette saves have no name, so write down the tape counter. LOAD does not clear memory first. It merges the new lines into whatever is there, replacing lines with the same numbers. That's handy for adding a library of modules, but type NEW first if you want a clean load.
Troubleshooting
- A J: or U: goes nowhere. The label is misspelled, or has a space in it.
*FRIEND SHIPis not a valid label. - The program runs off into the next module. A module called with
U:is missing itsE:. - Too many things match. M: finds items anywhere in the answer, so
M:NOalso matches "I KNOW". Use longer, more specific items. - A drawing disappears into the text window. Keep y above −31, or use
GR:QUITand redraw. - A merged mess after LOAD. You loaded on top of an old program. NEW, then LOAD again.
Further reading
- Atari PILOT Primer and Student PILOT Reference Guide (Atari, 1981): the official tutorial and command reference. The Primer covers the special
%variables for joysticks, paddles and the light pen. - Herb Kohl, Ted Kahn and Dale Disharoon, Atari PILOT Activities and Games (Reston, 1983), dozens of games plus a chapter of PILOT PEEKs and POKEs.
- Ken Harms, "Pilot Your Atari" column, Antic, 1982–83: colours, sounds and joystick tricks.
- On this site: Atari Logo Basics for the turtle's other home, and POKEY Sound Basics for the sound registers.
Credits
- Antic v1n6 (Feb 1983) — Ken Harms, Pilot Your Atari: Sounder — AtariMagazines.com (Kevin Savetz), 1983
- Antic v1n3 (Aug 1982) — Ken Harms, Pilot Your Atari: Colors For Your Pilot — AtariMagazines.com (Kevin Savetz), 1982
