Technology1 min read

How do you implement a random-access database when you don’t have random-access external storage?

By · Published by Everything Blog

In short

Relying solely on cassette tape ports with no automated playback controls, early Apple II machines could not support traditional external databases. Developers circumvented this limitation by writing a directory program that used POKE commands to overwrite dummy DATA statements directly inside its own memory image. While the monitor ROM allowed saving separate data memory blocks, doing so would require a tedious two-step loading procedure. Embedding the directory inside the program lines enabled users to save and load the code and data together using a single standard command.

Key points

  • Self-modifying BASIC code enabled functional database capabilities on systems completely…: Self-modifying BASIC code enabled functional database capabilities on systems completely lacking random-access external storage hardware.
  • Saving modified program lines bypassed the need for multi-step loading routines that sepa…: Saving modified program lines bypassed the need for multi-step loading routines that separately managed software code and raw memory blocks.
  • Storing records as executable statements successfully streamlined everyday user interacti…: Storing records as executable statements successfully streamlined everyday user interactions to a single cassette SAVE or LOAD operation.

Sources checked by our analysis pipeline: 1

The mystery comment investigated by Beej’s Bit Bucket reminded me of a similar trick in an Apple ][ telephone directory program.

The base Apple ][ was sold without a floppy drive. The only supported external storage device in the base unit was a cassette I/O port. Yet there was a database program for digitizing your phone list.¹ How did it do database stuff when the only I/O was a cassette drive? It could not programmatically start or stop the tape, or programmatically rewind or advance it.

If you took a listing of the program (which was written in BASIC), it began with a comment block saying not to edit any lines before line 1000. And then you saw your own telephone directory stored in DATA

statements.² Followed by a bunch of dummy DATA

statements. And then the program began.

Wait, how did your telephone directory show up as DATA

statements? The BASIC DATA

statement was a place for the program developer to store tables of precalculated read-only data, to be consumed by the READ

statement at runtime. They shipped the…

Technology