While translating a TRS-80 program into a ZX80 program, I crashed the system. I had already saved most of the program, so I loaded it again and proceeded to cut anywhere possible to save memory. When the program was as compact as I could get it, I ran it again. After a few inputs the program stopped. I quit for the day.
A couple of days later, I was writing directions for a game in a REM statement and accidentally pressed the shift key and the “/” key simultaneously. Instead of “/”, “NOT” appeared! I experimented more with this new technique and discovered that keywords as well as tokens could be typed into program lines in full—spaces and all—with practically a single keystroke.
This technique not only saves typing time, but, because a keyword or a token is usually stored as a single byte, it also saves memory. I went back to the program I had been translating and modified it with this technique. It ran perfectly.
Let us look at some examples of how the technique works.
The program line:
10 REM TO RUN, USE GOTO 100
written the ordinary way takes 24 bytes whereas with the above key and token technique it only takes 14 bytes, for a saving of 10 bytes. A line such as:
20 PRINT "ENTER YOUR NAME"
can be
20 PRINT "INPUT YOUR NAME" (INPUT underlined: the keyword)
for a saving of 4 bytes.
In a line like
30 LET Z$="JIM AND JOE" (AND underlined: the token)
you save 8 bytes by using the token “AND”.
To use the technique in a line such as
100 PRINT "TO STOP PROGRAM,
INPUT S" (TO, STOP and INPUT underlined)
type the statement number. Next type the last keyword first; then back up using shift “5” and enter the next to last keyword and so on until all keywords are entered. After that, type the keyword that uses the keyworded-characterstring either REM, PRINT or a characterstring, then type the tokens in their respective places. Finally, type any alphanumerics. The technique used in the above line saves 9 bytes.
If the keyword or token is preceded by another keyword or token, the preceding space of the following expression is omitted. If there is an alphanumeric between keywords or tokens, the spaces of each remain the same. More information can be found on page 105 of your ZX80 operating manual. I hope you find this technique as useful as I have.
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.