Saltar al contenido

How to write a basic Apple II program in your web browser

How to write a basic Apple II program in your web browser

Introduced in 1977, Apple ii was launched as part of a class of small, inexpensive computers made possible by microprocessor technology. These personal computers have allowed people to own and operate their own machines with relative ease. Before that, most computers were expensive and owned (or shared) only by large organizations.

Apple II stood out with its reduced graphics and color. It also had seven internal expansion slots that powered the world’s most expensive floppy disk system at the time, Disk II. circuit design co-founder of Apple, Steve Wozniak, allowed all these features to fit in a small office machine with a lightweight plastic housing.

Apple II was a great success for Apple. During its lifespan of about 16 years (it was discontinued in 1993), the Apple II platform hosted seven versions of the original design of the Wozniak computer. A typical Apple II computer was equipped with 48 or 64 KB of RAM and a 6502 processor at 1,022 MHz. You can program all models in BASIC.

The basics

From the late 1970s to the early 1980s, most personal computers included a programming language known as BASIC, an acronym for All-Purpose Symbolic Instruction Code for Beginners. BASIC appeared in 1964 in Dartmouth College timeshare system. It has quickly become a popular educational tool for computing due to its ease of use.

Apple II came with two major versions of BASIC over the years: Wozniak’s Integer BASIC and Applesoft. Microsoft created Applesoft long before it became famous for Windows.

For this article, we use Applesoft BASIC.

Some syntax tips

All BASIC programs on the Apple II are made up of lines of code. Each line has a number, and when a program is run, the computer runs each line in numerical order from smallest to largest. Each line is entered into the computer’s memory by pressing the Return key.

These three basic basic commands will always be useful.

  • At any time during programming, you can view the contents of your program by typing LISTcommand.
  • To start a new program (deleting the current program from memory), type NEW.
  • To clear the screen, type THE HOME.

If you make a mistake while typing the program, Apple II will return a «SYNTAX ERROR» when you run the program, including a line number where the error occurred. Just rewrite the offensive line, double-checking for possible error errors.

Did you understand? Let’s begin.

Your first schedule

First, we will write a very simple program that counts forever. It’s a quick way to test if BASIC is working properly on any system.

If you have a real Apple II, turn it on. Be sure to use an Applesoft ROM machine, such as an Apple II Plus or later, or a genuine Apple II with the correct language card.

If you’re watching without a real Apple II, open a new browser window at Apple Emulator] [js . Apple] [js usa JavaScript para simular los circuitos de un Apple II real en software. Básicamente, ejecutará un sistema Apple II completo en un navegador web (funciona mejor en Google Chrome).

Cuando carga el emulador por primera vez (o inicia un Apple II sin un sistema de disquete), verá una pantalla como la que se muestra a continuación.

La pantalla de inicio en Apple] [js.

Presione o haga clic en «Restablecer».

Presione "Restablecer".

Oirá un pitido y luego verá un mensaje “]»With an intermittent cursor.

An Apple II "]" and a cursor.

When prompted, type the following and press Enter (or Return) at the end of each line:

10 X = X + 1
30 GOTO 10

If you make a mistake, simply use the left arrow key on the keyboard to move the cursor back and make corrections. The new characters you type will overwrite the old ones. You can also rewrite the entire line.

Each time you write a line of code with a certain line number, BASIC replaces what was previously stored in that line number with the new entry.

BASIC program "10 X = X + 1", "20 PRINT X" and "30 GOTO 10" on Apple II.

When using BASIC on an older system, such as the Apple II, it is common to number the lines in multiples of 10. This gives you space to add new lines of code between them later, if necessary.

Then type LISTand then press Enter (or Return) to see a list of your program.

"List" of the BASIC program "10 X = X + 1", "20 PRINT X" and "30 GOTO 10" in Apple II.

If you accidentally end up with lines you don’t need (for example, if you typed 32 instead of 30), just type in the line number and press Enter (or Return) to delete it.

If all goes well, it’s time to run the program. Scribe RUNat the]prompt, then press Enter.

Exit the Apple II counting program.

The program counts one by one forever and prints each number on a new line at the bottom of the screen.

To stop the program, press Ctrl + C. That will PAUSEthe program, interrupting its execution.

A "Break" command in the counting program on the Apple II.

So how does this program work? Let’s divide it line by line:

10 X = X + 1
30 GOTO 10
  • Line 10: Here, we tell the program that a variable called «X» is equal to itself. At the beginning of the program, «X» is equal to zero. So on its first pass, the program adds one to zero, resulting in one.
  • Line 20: The program will use the file PRINTcommand to display the contents of the variable «X» on the screen.
  • Line 30: We use GO TOcommand to send the program back to line 10 in a loop. The value of the variable «X» (now increased by one) is returned to line 10. The program then repeats this process forever, counting one by one and then printing the result in each cycle.

A simple entry program

Now that you’ve tried to write, display, run, and break a program, let’s take a look at one that can do something with the input it gives you.

First, write NEWand press Enter. It removes our last program from memory so we can start over.

Type the following line by line, then press Enter (Return) at the end of each:


When it’s over, LISTthe program will check again that you typed it correctly.


Then type RUNand press Enter to return it. The program will ask you for information with a question mark ( ?). Type your name and press Enter to return to the question.

The naming program running in BASIC on Apple II.

Like some kind of dark arcane magic, the program knew your name and answered you. How did it work? Let’s take a look at each line:

  • Line 10: the program displays a line of text on the screen. Each line of text you want PRINTmust be in quotation marks.
  • Line 20: The program asks you ENTRYand store the result in a variable called N $. The dollar sign is short for «string». Each variable that includes letters must be a string variable.
  • Line 30: the displayed program Hello, followed by a comma and a space, then prints the contents of the variable N $. The semicolon told the program to print N $on the same line without entering a line break.

Scraping the surface

An illustration of people using Apple II computers in the 1978 Applesoft BASIC Manual.