beautypg.com

Apple IIe User Manual

Page 38

background image

Page 38 of 74

IIe
Printed: Tuesday, March 4, 2003 10:40:15 AM

80 INPUT N2$

Displays ? on the screen.

Whatever name you type is

stored in variable N2$.

90

PRINT

Prints a blank line.

100

PRINT THE C1$;

ROBOT 110

PRINT WITH THE C2$; EYES 120

PRINT

GRABBED N1$; WHILE 130

PRINT N2$; RAN FOR HELP.

Prints what's inside the quotation marks
interspersed with the colors and names you assigned
to the variables.

140

END

Signals the end of the program.

After you type RUN, your display will look something like this:

COLOR?

GREEN ANOTHER COLOR?

PURPLE NAME?

ROY ANOTHER NAME? HEATHER

THE GREEN ROBOT WITH THE PURPLE EYES GRABBED ROY WHILE HEATHER RAN FOR HELP.

You can use this same program to create your own sentences.

In fact, you may want to write a

program that creates a whole story.

Important!

When you choose variable names, be sure that you don't choose a word that is an Applesoft BASIC
reserved word.

Not even part of a variable can be a reserved word.

For example, a variable

can't be named LETTER because the reserved word LET is part of the name.

Reserved words are listed earlier in this chapter.

And don't forget the two-character rule:

Applesoft BASIC looks at only the first two

characters of a variable name.

If in the Crazy Sentence program the variables were named

NAME1$ and NAME2$, Applesoft BASIC would have created only one variable.

Printing Your Programs on Paper

If you have a printer connected to your computer, you can print a copy of your program on paper
using the LIST command.

This is useful in debugging programs.

Here's how:

Turn on your printer.
Type PR#1 to direct all information to your printer.
Type LIST
Type PR#0 to send information back to the screen instead of to the printer.
PR What?
PR#1 is shorthand for print to the device attached to slot 1.

You've Only Begun to Program

Now that you've made your way through this chapter, you know enough to write a few simple BASIC
programs.

To go further with Applesoft BASIC, ask your Apple dealer for the Applesoft

Tutorial.

It's a gentle introduction to BASIC that shows you how to write programs that

produce animated color graphics, in addition to programs like the ones in this chapter that
manipulate words and numbers.

From there, you can graduate to the Applesoft BASIC Programmer's

Reference Manual, a two-volume set that is the BASIC programmer's primary source of information
on the Applesoft BASIC programming language.