Program for creating a directory of programs on a tape.
This program is a cassette tape catalogue manager for the ZX81/TS1000, allowing users to store, view, revise, delete, and print records of up to ten cassette files, each holding up to ten named programs with tape counter start and end positions. Data is held in parallel arrays: C$(10,4) for load-mode strings, N$(10,15) for cassette names, P$(10,10,15) for program names, and T(10,10,2) for tape counter values. The print-label routine uses block-graphic border strings (X$, Y$, Z$) sent to the printer via LPRINT to produce formatted cassette inlay cards. The program saves itself with its data arrays using SAVE S$ and warns users via a start-up screen not to RUN it (which would reinitialise variables) but instead to GOTO 1.
Program Structure
The program is organised as a dispatcher with a main menu loop and a set of subroutines, each entered via GOSUB from lines 501–507. The overall flow is:
GOTO 280at line1skips the variable initialisation block on a cold start; the warning screen at lines200–270explains whyRUNmust not be used.- Lines
10–170: global variable and array initialisation. - Lines
280–540: main menu loop.FASTmode is set at line320for display speed. - Lines
550–970: Create File subroutine. - Lines
1000–1360: View File subroutine. - Lines
1370–1860: Revise File subroutine. - Lines
1900–2330: Delete File subroutine. - Lines
2340–2640: Print Label subroutine. - Lines
2680–2900: Save Files / Erase All subroutine. - Lines
2930–3080: Auto-run save routine (shared with Save Files path).
Data Structures
| Variable | Dimensions | Purpose |
|---|---|---|
C$(10,4) | 10 files × 4 chars | Load mode (“NORM” or “%F%/%L”) |
N$(10,15) | 10 files × 15 chars | Cassette name |
P$(10,10,15) | 10 files × 10 programs × 15 chars | Program names |
T(10,10,2) | 10 files × 10 programs × 2 | Tape counter FROM / TO values |
TF | scalar | Total files created so far |
F | scalar | Current file index |
X | scalar | Flag: 1 = reinitialise arrays after erase |
S$ | string | Program save name on tape |
Notable Techniques
- Self-saving with data: The
SAVE S$at line3060saves the entire program including all populated arrays, so the catalogue persists across sessions without a separate data file. - Blank-entry field revision: The Revise subroutine (lines
1370–1860) testsIF M$=""after eachINPUT; pressing ENTER with no text leaves the field unchanged, a clean idiom for in-place editing. - Block-graphic borders for printer labels:
X$(line170) is a full-width row of▌/▛/▀characters,Y$(line180) a dotted separator, andZ$(line190) a blank interior row, all used withLPRINTto frame the cassette label output. - Deletion by array shifting: When a file is deleted (lines
2030–2110), all higher-numbered entries are shifted down by one index in all four arrays, maintaining contiguous file numbering without gaps. - Erasure padding: After shifting, the vacated top slot is overwritten with spaces from
E$(a 32-space string) and zeros, preventing stale data from appearing as a ghost record. - FAST/SLOW idiom:
FASTis set at line320for the menu, andSLOWat line3030beforeSAVE, which requires the normal video timing to operate correctly. - Key-wait for printer: Lines
2460–2470usePAUSE 3200followed by anINKEY$busy-wait loop — a common ZX81 idiom for “press any key to continue” that survives aPAUSEtimeout.
Bugs and Anomalies
- Dead code after
GOTOat line1920: Line1920readsIF F<=TF AND F>=1 THEN GOTO 4070. Line4070does not exist in the listing, so a valid file number causes a4070error or jump to undefined behaviour. The intended target is probably line1960, which displays the file details before confirming deletion. Lines1960–1950are therefore unreachable as written. - Erase-all flag logic: The “Erase All” subroutine (line
2860) callsCLEARand then setsX=1(line2890). Back in the main loop, line530checksIF X=1 THEN GOTO 30, which re-runs theDIMstatements, effectively reinitialising the arrays. However, becauseCLEARhas already wiped all variables includingX, the check at line530will always seeX=0— meaning the arrays are never re-dimensioned after an erase. The flagXis set at line2890afterCLEAR, so it does survive to line530; this does in fact work as intended on closer inspection, sinceX=1is set after theCLEAR. - Line
3050jump target:IF INKEY$="" THEN GOTO 9999— line9999does not exist; this is presumably intended as an infinite wait loop but would cause an error if triggered while no key is pressed (though in practicePAUSE 3200preceding it means the user has had time to press a key). - Missing
SLOWat save:SLOWappears at line3030before the key-wait, but theINKEY$loop at3050means the program never actually falls through to3060when a key is not pressed — see the anomaly above. - Line
2910–2920dead code:PRINTandREMat lines2910–2920are unreachable; the Save subroutine falls through to line2930directly from line2780or2760.
Content
Source Code
1 GOTO 280
10 LET S$="CASSFILE*1"
20 REM "CASSFILE"
30 DIM C$(10,4)
40 DIM N$(10,15)
50 DIM P$(10,10,15)
60 DIM T(10,10,2)
70 LET X=0
80 LET F=0
90 LET E$=" "
100 LET A$="LOADING MODE:"
110 LET B$="CASSETTE NAME"
120 LET F$="FILE NO."
130 LET G$="PROGRAM NAME"
140 LET H$="TAPE COUNT"
150 LET I$="FROM TO"
160 LET TF=0
170 LET X$="\:'\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\':"
180 LET Y$="\:.\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\.:"
190 LET Z$="\: \ :"
200 PRINT AT 8,11;"""NOTE"""
210 PRINT AT 8,0;"DONOT ""RUN""THE PROGRAM","""USE GOTO 1"""
220 PRINT
230 PRINT "IF YOU DO,IT WILL CLEAR ALL THE VARIABLES.",,,,
240 PRINT "THAT MEANS YOU HAVE TO START OVER WITH EVERTHING."
250 PRINT
260 PRINT TAB 16;"11-16-84 ";"""RGS"""
270 PAUSE 480
280 CLS
290 REM ********
300 REM **MENU**
310 REM ********
320 FAST
330 PRINT S$
340 PRINT TAB 12;"MENU."
350 PRINT "--------------------------------"
360 PRINT
370 PRINT "1. CREATE FILE"
380 PRINT ,,"2. VIEW/PRINT FILE"
390 PRINT ,,"3. REVISE FILE"
400 PRINT ,,"4. DELETE FILE"
410 PRINT ,,"5. PRINT CASSETTE FILE"
420 PRINT ,,"6. SAVE FILES"
430 PRINT ,,"7. ERASE ALL FILES"
440 PRINT AT 19,5;"""INPUT YOUR CHOICE"""
450 PRINT
460 PRINT "--------------------------------"
470 INPUT M
480 IF M<1 OR M>7 THEN GOTO 440
500 CLS
501 IF M=1 THEN GOSUB 550
502 IF M=2 THEN GOSUB 1E3
503 IF M=3 THEN GOSUB 1370
504 IF M=4 THEN GOSUB 1900
505 IF M=5 THEN GOSUB 2340
506 IF M=6 THEN GOSUB 2680
507 IF M=7 THEN GOSUB 2820
520 CLS
530 IF X=1 THEN GOTO 30
540 GOTO 340
550 REM <<<<%C%R%E%A%T%E% %F%I%L%E% %S%U%B>>>>
560 LET F=TF+1
570 IF F<=10 THEN GOTO 610
580 PRINT "**NO SPACE FOR ANOTHER FILE**",,,"ON RETURN TO MENU CHOOSE SAVE","OPTION TO KEEP CURRENT FILES","THEN ERASE FILES AND START NEW","FILE ARRAY."
590 PAUSE 300
600 RETURN
610 PRINT "READY TO CREATE FILE NO.";F
620 PRINT AT 2,0;"INPUT SAVE/LOAD MODE: ",,,;"""NORM"" FOR NORMAL LOADING","""%F%/%L"" FOR ZXLR8 FASTLOADING ","ROUTINE."
630 INPUT C$(F)
640 CLS
650 PRINT TAB 18;F$;F
660 PRINT AT 2,0;E$;AT 2,0;B$;"?(15 CHRS MAX)"
670 INPUT N$(F)
680 PRINT AT 2,0;E$;AT 2,0;"INPUT PROG.NAMES AND TAPE COUNTS"
690 FOR N=1 TO 10
700 PRINT AT 4,0;"PROGRAM ";N
710 PRINT G$;" ? (15 CHRS MAX)"
720 INPUT P$(F,N)
730 PRINT AT 5,0;E$;AT 5,0;H$; " FROM ?"
740 INPUT T(F,N,1)
750 PRINT AT 5,11;"TO ? "
760 INPUT T(F,N,2)
770 PRINT AT 5,0;E$;AT 5,0;"ANOTHER PROGRAM ?(Y/N)"
780 INPUT M$
790 IF M$="N" THEN GOTO 820
800 IF M$<>"N" AND M$<>"Y" THEN GOTO 770
810 NEXT N
820 CLS
830 LET TF=TF+1
840 PRINT AT 8,2;"(C)REATE ANOTHER FILE."
850 PRINT
860 PRINT TAB 2;"(V)IEW CREATED FILE."
870 PRINT
880 PRINT TAB 2;"(M)ENU."
890 PRINT AT 18,5;"INPUT C,V OR M."
900 INPUT M$
910 IF M$<>"C" THEN GOTO 950
920 LET F=F+1
930 CLS
940 GOSUB 610
950 CLS
960 IF M$="V" THEN GOSUB 1040
970 RETURN
980 REM **********************
990 REM ***VIEW FILE SUB***
\n1000 REM **********************
\n1010 PRINT AT 12,5;"WHICH FILE NUMBER ?"
\n1020 INPUT F
\n1030 REM **ENTRY FROM OTHER SUBS**
\n1040 CLS
\n1050 IF TF<>0 AND F<=TF AND F>=1 THEN GOTO 1130
\n1060 PRINT """NO FILE WITH THAT NUMBER."""
\n1070 PRINT "MENU (M) OR OTHER FILE (V)"
\n1080 INPUT M$
\n1090 IF M$="V" THEN GOTO 1010
\n1100 IF M$="M" THEN RETURN
\n1110 PRINT "FOLLOW INSTRUCTIONS PLEASE"
\n1120 GOTO 1070
\n1130 CLS
\n1140 PRINT F$;F
\n1150 PRINT ,,A$;C$(F)
\n1160 PRINT "********************************"
\n1170 PRINT G$;TAB 20;H$;TAB 20;I$
\n1180 PRINT "--------------------------------"
\n1190 FOR N=1 TO 10
\n1200 PRINT N;".";P$(F,N);TAB 20;T(F,N,1);TAB 26;T(F,N,2)
\n1210 NEXT N
\n1220 PRINT AT 21,0;"(P)PRINT,(N)NEXT FILE,OR (M)MENU"
\n1230 INPUT M$
\n1240 PRINT AT 21,0;E$
\n1250 IF M$="P" THEN COPY
\n1260 IF M$<>"N" THEN GOTO 1350
\n1270 LET F=F+1
\n1280 IF F<=TF THEN GOTO 1340
\n1290 CLS
\n1300 PRINT AT 11,1;"**NO FILE OF HIGHER NUMBER**"
\n1310 PAUSE 150
\n1320 CLS
\n1330 GOTO 1350
\n1340 GOSUB 1040
\n1350 RETURN
\n1360 STOP
\n1370 REM ***%R%E%V%I%S%E% %F%I%L%E% %S%U%B***"
\n1380 PRINT AT 10,1;"WHICH FILE TO REVISE? (1-10)"
\n1390 PRINT
\n1400 PRINT TAB 4;"FILE NO.REQUESTED. ";
\n1410 INPUT F
\n1420 PRINT F
\n1430 PAUSE 180
\n1440 IF F<=TF THEN GOTO 1490
\n1450 PRINT
\n1460 PRINT TAB 6;"**NO SUCH FILE**"
\n1470 PAUSE 150
\n1480 RETURN
\n1490 CLS
\n1500 PRINT AT 8,0;"FILE ";F;" DETAILS WILL BE PRINTED.",,,"PRESS ENTER IF CORRECT.","INPUT NEW DETAILS IF REQUIRED."
\n1510 PAUSE 150
\n1520 SCROLL
\n1530 PRINT A$;C$(F)
\n1540 INPUT M$
\n1550 IF M$="" THEN GOTO 1600
\n1560 LET C$(F)=M$
\n1570 CLS
\n1580 SCROLL
\n1590 PRINT "NEW ";A$;C$(F)
\n1600 SCROLL
\n1610 PRINT B$;" ";N$(F)
\n1620 INPUT M$
\n1630 IF M$="" THEN GOTO 1700
\n1640 LET N$(F)=M$
\n1650 CLS
\n1660 SCROLL
\n1670 PRINT A$;C$(F)
\n1680 SCROLL
\n1690 PRINT "NEW CASS.NAME ";N$(F)
\n1700 SCROLL
\n1710 FOR N=1 TO 10
\n1720 PRINT "PROG.";N;" NAME ";P$(F,N)
\n1730 INPUT M$
\n1740 IF M$<>"" THEN LET P$(F,N)=M$
\n1750 PRINT AT 21,0;"PROG.";N;" NAME ";P$(F,N)
\n1760 SCROLL
\n1770 PRINT AT 21,0;"TAPE FROM:";T(F,N,1)
\n1780 INPUT M$
\n1790 IF M$<>"" THEN LET T(F,N,1)=VAL M$
\n1800 PRINT AT 21,0;"TAPE FROM:";T(F,N,1);" TO:";T(F,N,2)
\n1810 INPUT M$
\n1820 IF M$<>"" THEN LET T(F,N,2)=VAL M$
\n1830 PRINT AT 21,0;"TAPE FROM:";T(F,N,1);" TO:";T(F,N,2)
\n1840 SCROLL
\n1850 NEXT N
\n1860 RETURN
\n1870 REM **********************
\n1880 REM **DELETE FILE SUB**
\n1890 REM **********************
\n1900 PRINT "WHICH FILE DO YOU WISH TO DELETE ? (1 TO 10)"
\n1910 INPUT F
\n1920 IF F<=TF AND F>=1 THEN GOTO 4070
\n1930 PRINT "**NO FILE OF THAT NUMBER**"
\n1940 PAUSE 150
\n1950 GOTO 2330
\n1960 PRINT F$;F,,A$;C$(F)
\n1970 PRINT B$;" ";N$(F)
\n1980 PRINT AT 10,0;"INPUT D TO CONFIRM DELETION",,,"OR M FOR MENU."
\n1990 INPUT M$
\n2000 IF M$<>"D" THEN GOTO 2330
\n2010 PRINT AT 14,0;"ALL FILES WITH NUMBERS >";F,"WILL HAVE THEIR FILE NUMBERS","REDUCED BY ONE."
\n2020 IF F=TF THEN GOTO 2120
\n2030 FOR N=F TO TF-1
\n2040 LET N$(N)=N$(N+1)
\n2050 LET C$(N)=C$(N+1)
\n2060 FOR L=1 TO 10
\n2070 LET P$(N,L)=P$(N+1,L)
\n2080 LET T(N,L,1)=T(N+1,L,1)
\n2090 LET T(N,L,2)=T(N+1,L,2)
\n2100 NEXT L
\n2110 NEXT N
\n2120 LET C$(TF)=E$
\n2130 LET N$(TF)=E$
\n2140 FOR N=1 TO 10
\n2150 LET P$(TF,N)=E$
\n2160 LET T(TF,N,1)=0
\n2170 LET T(TF,N,2)=0
\n2180 NEXT N
\n2190 LET TF=TF-1
\n2200 CLS
\n2210 PRINT "FILE DELETED"
\n2220 PRINT ,,"NEW FILE LISTING:"
\n2230 PRINT
\n2240 FOR N=1 TO TF
\n2250 PRINT F$;N;" ";A$;C$(N)
\n2260 NEXT N
\n2270 PRINT AT 21,0;"COPY NEW LIST (C) OR MENU (M)"
\n2280 INPUT M$
\n2290 IF M$<> "C" THEN GOTO 2330
\n2300 PRINT AT 21,0;E$
\n2310 COPY
\n2320 CLS
\n2330 RETURN
\n2340 REM **********************
\n2350 REM ** PRINT LABEL SUB ***
\n2360 REM **********************
\n2370 PRINT AT 8,0;"WHICH FILE DO YOU WANT TO PRINT",,,"AS A CASSETTE LABEL?(1 TO 10)"
\n2380 PRINT
\n2390 INPUT F
\n2400 IF F>=1 AND F<=TF THEN GOTO 2450
\n2410 PRINT "**NO FILE OF THAT NUMBER**"
\n2420 PAUSE 150
\n2430 CLS
\n2440 GOTO 2640
\n2450 PRINT ,,"FILE ";F;" WILL NOW BE PRINTED.",,,"CHECK PRINTER,HIT A KEY TO START"
\n2460 PAUSE 3200
\n2470 IF INKEY$="" THEN GOTO 2470
\n2480 LPRINT X$;"\: ";A$;C$(F);TAB 20;F$;F; TAB 31;"\ :"
\n2490 LPRINT Z$;"\: ";B$;" ";N$(F); TAB 31;"\ :"
\n2500 LPRINT Z$;X$;"\: ";G$; TAB 20;"\: ";H$; TAB 31;"\ :"
\n2510 LPRINT "\: ";TAB 20;"\: ";I$;TAB 31;"\ :"
\n2520 LPRINT X$
\n2530 FOR N=1 TO 6
\n2540 LPRINT "\: ";N;" ";P$(F,N); TAB 21;T(F,N,1);TAB 25;T(F,N,2); TAB 31;"\ :";Z$
\n2550 NEXT N
\n2560 LPRINT Y$;X$
\n2570 LPRINT "\: ";A$;C$(F); TAB 20;F$;F; TAB 31;"\ :"
\n2580 LPRINT Z$;"\: ";B$;" ";N$(F); TAB 31;"\ :"
\n2590 LPRINT Y$;X$
\n2600 FOR N=7 TO 10
\n2610 LPRINT "\: ";N;" ";P$(F,N); TAB 21;T(F,N,1);TAB 25;T(F,N,2);TAB 31;"\ :";Z$
\n2620 NEXT N
\n2630 LPRINT Y$
\n2640 RETURN
\n2650 REM **********************
\n2660 REM ** SAVE FILES PROC **
\n2670 REM **********************
\n2680 CLS
\n2690 PRINT AT 6,0;"SAVE FILES ON TAPE ROUTINE"
\n2700 PRINT ,,"CURRENT PROGRAM NAME IS"
\n2710 PRINT ,," "" ";S$;" "" "
\n2720 PRINT ,,"INPUT A NEW NAME FOR THIS ","PROGRAM FILE OR PRESS ENTER","ONLY TO SAVE WITH CURRENT NAME."
\n2730 PRINT ,,"INPUT M FOR MENU"
\n2740 INPUT M$
\n2750 IF M$="M" THEN RETURN
\n2760 IF M$="" THEN GOTO 2930
\n2770 LET S$=M$
\n2780 GOTO 2930
\n2790 REM **********************
\n2800 REM *DELETE ALL FILES SUB*
\n2810 REM **********************
\n2820 PRINT "INPUT D TO CONFIRM ALL FILES","ARE TO BE DELETED."
\n2830 PRINT ,,"INPUT M TO RETURN TO MENU."
\n2840 INPUT M$
\n2850 IF M$<>"D" THEN GOTO 2890
\n2860 CLEAR
\n2870 PRINT ,,"INPUT NEW NAME FOR THIS FILE"
\n2880 INPUT S$
\n2890 LET X=1
\n2900 RETURN
\n2910 PRINT
\n2920 REM **********************
\n2930 REM ** AUTO-RUN ROUTINE.**
\n2940 REM **********************
\n2950 CLS
\n2960 PRINT AT 6,0;"PROGRAM NAME IS ";
\n2970 PRINT """ ";S$;" """
\n2980 PRINT
\n2990 PRINT TAB 6;"**NOTE IT DOWN**"
\n3000 PRINT
\n3010 PRINT ,,"SET CASSETTE TO RECORD,AND THEN","PRESS A KEY TO SAVE."
\n3020 PAUSE 3200
\n3030 SLOW
\n3050 IF INKEY$="" THEN GOTO 9999
\n3060 SAVE S$
\n3070 CLS
\n3080 GOTO 200
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
