Classic Computer Magazine Archive COMPUTE! ISSUE 36 / MAY 1983 / PAGE 143


Guess That Animal

Ralph Kennedy

This article adapts a previously published COMPUTE! program to the Sinclair ZX-81. It is also a brief tutorial on the special features of the ZX-81's BASIC, showing how you can reload programs without losing data previously saved. The program requires 16K.

This is an adaption for the Sinclair ZX-81 of Daniel Hastie's "Guess that Animal!" program, which appeared in the August 1982 issue of COMPUTE!. The 16K RAM pack is required.

The most significant difference between Hastie's versions (for PET and Atari) and the ZX-81 version is that no data tapes are used. The ZX-81 is not equipped to read or write such tapes, but it does save all variables and arrays when it saves programs. This means that if you play the game for a while and then save the program, it will be more "knowledgeable" when it is reloaded than it was in its pristine state.

Saving The Program

Incidentally, on those occasions when you have no need of a record of the values of the variables in a program you are saving, you can save an amount of time roughly proportional to the amount of memory set aside for variables and arrays simply by entering CLEAR before saving the program.

When you have typed this program into your ZX-81 and have assured yourself that all is well with it, enter CLEAR and save the program once so that you have on tape a reasonably quick-loading version without variables. Later, after you've played the game for some time and want to save program and data, simply respond with a N to the question "Would you like to try again?" and you will then see instructions on saving the data.

A version saved in accordance with these instructions will begin running automatically when it is loaded back into the computer. If you save the program by stopping it and entering SAVE, be sure to start it using GOTO START when you reload. Using RUN will wipe out all the data you spent so much time saving and loading.

ZX-81 BASIC Special Features

Two rather nice features of the ZX-81's BASIC are exploited in this program to aid in documentation and in ease of use. These are (1) its acceptance of long variables (with all characters being significant), and (2) its acceptance of such commands as GOTO MEMCHECK, GOSUB TRUNCATE, etc.

These features enable a programmer to write a well-documented program with fewer REM statements than would otherwise be needed, since lines like 467 GOTO MEMCHECK are reasonably self-documenting. They also make possible the use, mentioned above, of GOTO START to start a program without losing data or, when CONT doesn't work, to get back into a stopped program at the right place and without losing data.

Finally, these special features enable the programmer during debugging to use such commands as LIST GET or LIST ASK to list sections of the program where problems are suspected. All this can be quite handy for those whose memory for numbers leaves something to be desired. Just be sure that the first thing your program does is define the relevant variables, and you're in business.