BBC BASIC 2.31 for the Tatung Einstein, showing DRIFT, the text adventure the course builds, in the middle of a game
← Back to Courses
module
6

Keeping Your Work

Introduction

Everything so far has lived in the Einstein's memory, and memory forgets. OLD rescues you from a slip, but switch the machine off - or close MAME - and the program is gone for good.

The disc does not forget. This section puts your program on it, by name, and gets it back.

Saving

SAVE "FIRST"

writes the program in memory to the disc, in a file called FIRST. The name goes in double quotes. BBC BASIC says nothing - the > comes back when it has finished - and the program is still in memory, exactly as it was.

Saving again under the same name replaces the old file, without asking. That is what you want when you are saving your progress on the same program; it is not what you want if the name belonged to something else. Pick names you will recognise.

Loading

LOAD "FIRST"

reads the program back into memory, replacing whatever was there. Again, nothing is printed. LIST to see it, RUN to run it.

A name BBC BASIC cannot find on the disc gets File not found.

What Is On The Disc

*DIR

lists your programs. The star at the front tells BBC BASIC this is a command for the disc rather than a line of BASIC. On the course disc, with FIRST saved, you see:

0: FIRST   .BBC :*ANIMAL  .BBC

The 0: is the drive. .BBC is added to every program's name when it is saved, so you never type it. A star in front of a name means the file is locked - it can be read, but not overwritten without a question first. ANIMAL, the 1984 game on the disc, is locked, and that is deliberate.

*DIR *.* lists everything on the disc, not just programs - BBC BASIC itself is there, as BBCBASIC.COM.

Tidying Up

*REN FIRST TO SECOND

renames a program, and

*ERA SECOND

erases one. Neither says anything when it has worked. *ERA has no OLD: an erased program is gone.

The Code

10 PRINT "THIS PROGRAM WAS SAVED"
20 PRINT "AND LOADED BACK"

Type the two lines, then:

SAVE "FIRST"
NEW
LIST
LOAD "FIRST"
LIST
RUN
*DIR

Starting from

A fresh boot on the course disc.

What you should see

The first LIST shows nothing - NEW has cleared memory. The second shows the program again, loaded from the disc, and RUN runs it:

>RUN
THIS PROGRAM WAS SAVED
AND LOADED BACK
>*DIR
0: FIRST   .BBC :*ANIMAL  .BBC

The program saved, loaded and listed

Now restart the Einstein - close MAME and start it again, or switch off - start BBC BASIC, and type LOAD "FIRST" and RUN. It is still there.

Change One Thing

  • Type LOAD "FRIST", with the letters swapped. What does BBC BASIC say?
  • Change line 10, SAVE "FIRST" again, then NEW and LOAD "FIRST". Which version do you get back, and did BBC BASIC warn you?
  • Type *DIR *.*. What is on the disc that *DIR did not show you?

Exercises

6.1 Save the same program under a second name, SECOND, and check with *DIR that both are there.

6.2 Rename SECOND to THIRD, and check.

6.3 Erase THIRD, and check.

Worked solutions are in Appendix II.

When It Goes Wrong

SymptomCause
File not foundThe name is not on the disc - a typing slip, usually. *DIR shows what is.
No such variable after SAVEYou left out the quotes. SAVE "FIRST", not SAVE FIRST.
Bad command after *ERAThere is no file of that name to erase.
File Lock, Drive 0: and Unlock(Y/N)?You tried to save over a locked file - on the course disc, that means you typed SAVE "ANIMAL". Answer N: you drop out to 0:, but type BBCBASIC and then OLD and your program is back; save it under another name. Answering Y unlocks ANIMAL and overwrites it with your program, and the 1984 game is lost.
Bad Data, Drive 0: and Try Again(Y/N)?You are running from a .dsk image, which MAME will not write to (S2). N, then BBCBASIC and OLD, and restart with the course disc.
The program you loaded is not the one you were working onLOAD replaces what is in memory. Save first.

Summary

SAVE "NAME" puts the program on the disc and LOAD "NAME" brings it back, even after a restart. *DIR shows what is there, *REN renames and *ERA erases. Saving over a name replaces it without asking; a locked file asks, and the answer should be N.

Next

S7, Sums - BBC BASIC as a calculator, and how it shows the numbers it works out.

Get the Newsletter

New guides, disk images and community finds, roughly once a quarter. No spam, we promise, this isn't Tatung's marketing department.
Your subscription could not be saved. Please try again.
Your subscription has been successful.

Newsletter

Subscribe to our newsletter and stay updated.