Chapter 16 - Tape storage

As was mentioned in chapter 1, & you have no doubt found out from experience anyway, when you turn the ZX81 off you lose all the program & variables that were stored inside it. The only way to save these is to have the computer record them onto a cassette tape; & then later you can load them back in & the computer will be restored to practically the same state as it was in when it made the recording.

    You will have found that with the ZX81 a pair of leads (article (v) in chapter 1) which connect the ZX81 to a cassette recorder. You must provide your own tape recorder, & some work better than others.

    First, as far as the ZX81 is concerned, the cheap, portable mono cassette recorders are at least as good as expensive stereo ones, & give less trouble as well. You will find a tape counter very useful.

    Second, the tape recorder must have an input socket for use with microphones, & an optput socket for use with earphones if there isn't one, try the external loudspeaker socket.) They should preferably be 3.5 mm jack sockets i.e. to fit the jack plugs on the leads provided), because other sorts often do not give a signal powerful enough for the ZX81.

    Any cassette tape should work, although low noise tapes are preferable.

    Now, having acquired a suitable cassette recorder, connect it to the computer: one lead should connect the microphone input socket on the recorder to the socket marked 'MIC' on the side of the ZX81, & the other connects the earphone output socket on the recorder to the 'EAR' socket on the ZX81. Make sure that the leads are not crossed over (although you won't damage the ZX81 if they are.)

    Type some program into the computer, say the character set program in chapter 11. You are going to have to give the program a name when you save it, & it is a good idea to put this name into the program so that it appears in listings - the easiest way is with a REM statement. So type

        5 REM "CHARACTERS"

    Now - & this is just a dry run, so that you can see what happens, - type


& watch the television. For five seconds it will just be a greyish colour, then for about six seconds there will be a distinctive pattern of thin black & white stripes, & then the screen will go white with the report 0/0. The computer was sending a signal to the 'MIC' socket; but it was also sending the same signal to the television, producing the picture that you saw. The grey part was a silent lead-in, & the black & white part was the program.

    What you want to do, of course, is catch that signal on tape, so let's do it properly this time.

Saving a program

1. Position the tape in a part either that is blank, or that you are prepared to overwrite.

2. Using a microphone, record yourself saying 'characters'. This is not essential, but it will make it easier to find the program afterwards. Reconnect the computer to the tape recorder.

3. Type

       SAVE "CHARACTERS"       (withoutNEWLINE)

4. Start the tape recorder recording.

5. Press NEWLINE.

6. Watch the television as before. When it has finished (with the report 0/0), stop the tape recorder.

    To make sure that this has worked, you should now listen to the tape through the tape recorder's own loudspeaker. (You will probably have to unplug the lead from the earphone socket on the tape recorder.) Rewind the tape to where you started before, & play it back.

    First, you will hear your own voice saying 'characters'.

    After that, comes a soft, humming buzz. This is not really part of the recording, but the end of the signal for the television (before you pressed NEWLINE), which happens to have been sent to the tape recorder as well.

    Next come five seconds of silence, the beginning of the proper tape signal. This corresponds to the period when the television screen went grey.

    Next come about six seconds of a very harsh high-pitched buzz, & at full volume this should be very unpleasantly loud. This is a recording of the program, & corresponds to the black & white patterns on the television screen.

    Finally, the soft humming buzz will return.

    If you did not hear these various hums & buzzes, then check that you had the computer & tape recorder properly connected up. It happens with some tape recorders that the jack plug dies not make contact if it is pushed right in. Try pulling it out about a tenth of an inch - you can sometimes feel it settling down into a more natural position.

    Now let us suppose that the recoding sounds all right to the human ear, & you want to try to load it back into the computer.

Loading a program with a name

1. Rewind the tape to the place where you started.

2. Make sure that the 'EAR' socket on the computer is connected to the earphone socket on the tape recorder.

3. Turn the volume control on the tape recorder to about three quarters of the maximum volume; if it has tone control then adjust them so that treble is high & bass is low (so that it sounds hissy).

4. Type

       LOAD "CHARACTER" (again, without NEWLINE)

5. Start the tape recorder playing.

6. Press NEWLINE.

    Again, you will be able to see pictures of the recording in the television, but they will look different this time, everything being a black & white pattern. The two parts, the silence & the program, will be less easily distinguished, but you should be able to see that the program part has much broader, more defined lines. (Try exercise 1 some time.)

    After fifteen seconds it should have loaded & stopped with report 0/0. Otherwise, press the BREAK key (space), which should let it out of its misery.

    The most likely thing to have been wrong is the volume level: this should be

    (i) loud enough for the program part to be picked up by the computer,

    (ii) not so loud that the program part is distorted (this is actually fairly rare),

& (iii) quiet enough for the silent part to be recognized as silent by the computer.

    The best adjustment is to turn the volume up as loud as it will go without making the silent part at all noisy; you can do this while listening to the recording through the loudspeaker. If the silence is incorrigibly noisy, then you may have other problems:

    Some tape recorders form a feedback loop with the ZX81. This can only happen when the EAR & MIC leads are both in at the same time, so the cure is to SAVE with the EAR lead disconnected.

    Some tape recorders can record a mains hum. This is cured by operating them on batteries.

   Some tape recorders - especially old, worn ones - are intrinsically noisy. This may be helped by using a better quality tape, although this should not be necessary.

    Try cleaning the tape head in the cassette recorder, in case it is dirty.

    Finally, there may be the same problem about pushing the plug right into the earphone socket as was mentioned for the microphone socket.

    If you've got a program on tape & you can't remember its name, you can still load it. (Try this with the program "CHARACTERS" that you were using before.)

Loading a program without a name

1. Position the tape in the silent lead-in.

2. Check everything & adjust the controls as before. You might well find that you have to be more careful with the volume level than you did when you knew the name.

3. Type

       LOAD "" (without NEWLINE)

4. Start the tape recorder playing.

5. Press NEWLINE.

6. The rest is as before.

    The idea is that if the name of the program you ask to be loaded is the empty string, then the computer loads the first program it comes across. Note that when you save a program, you cannot make its name the empty string - if you try then you will get error F.

    LOAD & SAVE can also be used in programs. With SAVE, the program will save itself in such a state then when loaded it will immediately carry on executing from the line after the SAVE statement.

    For example, type in

        5 REM "USELESS"


        20 STOP

        100 SAVE "USELESS"

        110 GOTO 10

    Connect up the tape recorder, type

       RUN 100 (without NEWLINE),

start the tape recorder recording, & press NEWLINE. When the program has saved itself, it will continue running. You will discover afterwards that the last S in USELESS in line 100 has changed to inverse video, but this is nothing to worry about.

    To load it, rewind the tape to somewhere before the beginning of the program, type

       LOAD "USELESS" (without NEWLINE),

start playing back the tape into the computer, & press NEWLINE. When it has loaded, it will carry on with line 110 & execute itself without any effort on your part.

    Note how putting the SAVE statement at the end of the program means that to run it without the SAVE you just type RUN - you don't have to jump round the SAVE statement.

    Don't SAVE from within a GOSUB routine - it won't work properly.

    Don't put inverse video characters in a program name. Any part of the name after the inverse video character gets lost.

    The name should not contain more than 127 characters.

    The name in a LOAD or SAVE does not have to be a string constant, it can be any string-valued expression, like A$ or CHR$ 100.


    Saving a program on tape

    Loading a named program from tape

    Loading the first available program from tape

    Saving a program so that it will load & then run itself

    Statements: SAVE, LOAD


    You cannot load programs that were saved from any other kinds of computer or from the ZX80 with its own integer BASIC. Your saved programs cannot be loaded into other kinds of computer or the ZX80 with integer BASIC. The ZX80 with ZX81 BASIC, on the other hand is compatible with the ZX81; saved programs from either can be loaded to the other. After loading a ZX80 program, the ZX81 will be in fast mode.


1. Make a tape with loads of short programs, start playing it back into the computer, & type


You should easily be able to see the difference on the television between the empty stretches on the tape (with a fairly unstructured black & white pattern) & the programs (with more definite lines). Both patterns are different from what you see when you save. If you turn the volume down while a program is going past, you can see the picture switching to the empty space pattern while the signal goes too quiet to look like program.

2. Make a tape on which the first program, when loaded, prints a menu (a list of the other programs on the tape), asks you to choose a program, & then loads it.

3. Type in the program "CHARACTERS" again, & then type

       LET X=7

so that - although it doesn't appear in the program - the computer now contains a variable X with value 7. Now save the program, turn the computer off & on (to make sure there's no cheating), & load the program back again. Type

       PRINT X

& you will get the answer 7. The SAVE statement saved not only the program, but also all the variables - including X.

    If you want to keep these variables when you execute the program, you must remember to use GOTO & not RUN (as was mentioned in chapter 9). You can avoid having to remember this by making the program execute itself (using SAVE as a program line).

4. Type in a very long program, & them momentarily disconnect the power supply. This sort of thing sometimes happens spontaneously; it is not a bug, but a glitch. There is nothing you can do about it except cry. It if happens more often than you can bear then there is probably something wrong, but it would be worth saving the incomplete program on tape half-way through.

Previous: Chapter 15    Next: Chapter 17