This is a multi-file data storage and display system for the ZX81/TS1000, written in 1982 by Al Bandy for ZX-Panding, Ltd. of Newton, NC. It manages up to 25 named files, each holding up to 60 numeric data points, with menu-driven options to open, enter, correct, list, graph, and save files to cassette tape. The program tracks per-file minimum and maximum value indices in separate arrays (L and N arrays), computes running means and sums, and renders a column bar graph using PLOT with dynamic scaling to fit the display. Initialization is separated into lines 2000–2090, which must be run first via GOTO 50 (actually line 2000 area), then the main program re-entered at line 50 after dimensioning.
Program Structure
The program is split into three logical regions:
- Lines 1–5: Boot-guard warning. If the user accidentally hits RUN, these lines print a warning not to do so, then
STOP. They advise re-entering viaGOTO 50(which would reach line 100 via the nearest executable line). - Lines 100–970: Main menu loop and all user-facing operations (open file, list titles, enter data, correct data, tabular list, graph, save, end).
- Lines 1000–1920: Subroutines — data entry (1000), min/max tracking (1200), file-title lister (1300), file stats/tabular display (1400), graphing engine (1500–1670), return-to-menu prompt (1800), and keypress-wait input (1900).
- Lines 2000–2090: One-time initialization: dimensions all arrays and seeds
LandHto 1, thenSTOPs.
Array Layout
| Array | Dimensions | Purpose |
|---|---|---|
D(F,60) | 25×60 | Numeric data points per file |
E(60) | 60 | Scaled copy of a file’s data for graphing |
H(F) | 25 | Index of highest value in each file |
L(F) | 25 | Index of lowest value in each file |
N(F+1) | 26 | Point count per file (dimensioned F+1 for safety) |
Q$(F,10) | 25 strings of 10 chars | File titles |
Key BASIC Idioms
- Keyword-highlighted text: Strings like
"%D%A%T%A%"use the ZX81’s inverse-video character encoding triggered by%— each%-prefixed letter prints in inverse, producing bold/highlighted words on screen. - GOSUB 1900 keypress wait: Lines 1903–1905 first flush any held key (
IF INKEY$<>"" THEN GOTO 1903), then wait for a fresh keypress (IF INKEY$="" THEN GOTO 1905), storing the result inU$. This is a standard ZX81 single-key input pattern. - File-title display in two columns (lines 1310–1350): The subroutine at 1300 increments
Itwice per printed line, usingTAB 16for the second column. - FAST/SLOW toggling:
FASTis set during computation-heavy sections;SLOWis restored before interactive input and display, as required for the ZX81’s video generation.
Graphing Engine (Lines 1500–1670)
The graphing routine copies file I‘s data into array E, then iteratively scales it to fit within a 24–37 unit display range. If the data spread (X) exceeds 37, values are divided by 1.5; if below 24, they are multiplied by 1.5. The loop at lines 1540–1570 feeds back into line 1520 until the range fits. This is a heuristic convergence loop with no guaranteed termination if data is pathological, though for typical datasets it converges quickly.
The actual graph is drawn with PLOT J+1, K inside a nested loop (lines 1640–1665), drawing a vertical bar from row 4 up to the scaled value for each data point. The X-axis label at line 1637 uses block-graphic characters (\'' = ▀) to mark positions 1, 10, 20, 30, 40, 50, 60.
Min/Max Tracking Subroutine (Lines 1200–1220)
Rather than scanning the whole array, the subroutine at 1200 updates H(I) and L(I) incrementally each time a new data point is entered. This is efficient for sequential entry but means corrections (option 4) do not recalculate the min/max indices — a known limitation. If a corrected value changes the true minimum or maximum, H and L will be stale.
Bugs and Anomalies
- GOTO 50 vs. line 50: Lines 1–5 and 2020–2030 instruct the user to
GOTO 50, but there is no line 50 in the program. The ZX81 will jump to the next available line, which is line 100 (main menu). This works correctly only if initialization (line 2000) has already been run; otherwise arrays are undimensioned. - Stale min/max after correction: Option 4 (correct a point) calls
GOSUB 1200after the fix, which only updatesH/Lif the new value exceeds the current tracked extremes. A correction that lowers the current maximum or raises the current minimum will leave incorrect range indices. - Line 1020 references
L(I)before any data is entered: On a freshly opened file,L(I)=1andH(I)=1, soD(I,1)is displayed as both low and high (value 0). This is cosmetically odd but not a crash. - Graphing uses
E(H(I))andE(L(I))after copy (line 1520):H(I)andL(I)are indices into the originalDarray, reused as indices intoE. SinceE(J)=D(I,J)is a direct copy, the same indices are valid — this is correct but relies on the positional correspondence being preserved. - Line 130: Three menu options (3, 4, 5) are concatenated into a single
PRINTstring with no separating newlines in the source, relying on the 32-character line wrap to produce the appearance of separate lines. This is fragile if display width assumptions change. DIM N(F+1)at line 2046: Dimensioned as 26 elements while all other file arrays are size 25 (F). The extra element provides a buffer against off-by-one access but is never explicitly used.
Content
Source Code
1 PRINT AT 6,9;"DO NOT HIT %R%U%N"
2 PRINT AT 8,1;"%Y%O%U% %H%A%V%E% %L%O%S%T% %D%A%T%A% %S%I%N%C%E% %L%A%S%T"
3 PRINT AT 10,5;"%L%O%A%D%I%N%G% %F%R%O%M% %C%A%S%S%E%T%T%E"
4 PRINT AT 13,4;"REENTER AND USE %G%O%T%O% %5%0"
5 STOP
100 FAST
105 CLS
108 PRINT
110 PRINT "%D%A%T%A% %S%T%O%R%A%G%E% %A%N%D% %D%I%S%P%L%A%Y% %S%Y%S%T%E%M COPYRIGHT 1982 BY AL BANDY FOR:%Z%X%-%P%A%N%D%I%N%G%,%L%T%D%.,BOX 25"
112 PRINT TAB 7;"NEWTON,NC 28658"
120 PRINT AT 7,11;"%M%E%N%U"
125 PRINT AT 9,0;"1-OPEN A NEW FILE"
128 PRINT "2-LIST FILE TITLES"
130 PRINT "3-ENTER DATA INTO EXISTING FILE 4-CORRECT A POINT IN A FILE 5-TABULAR LISTING OF A FILE 6-GRAPH A FILE"
136 PRINT "7-SAVE ON TO TAPE"
137 PRINT "8-%C%L%O%S%E% %O%U%T% %A% %F%I%L%E"
138 PRINT "9-%E%N%D"
140 PRINT
145 PRINT " %T%O%U%C%H% %J%O%B% %N%U%M%B%E%R% %D%E%S%I%R%E%D"
150 GOSUB 1900
160 IF U$="1" THEN GOTO 300
162 IF U$="2" THEN GOTO 550
164 IF U$="3" THEN GOTO 450
166 IF U$="4" THEN GOTO 600
168 IF U$="5" THEN GOTO 700
170 IF U$="6" THEN GOTO 750
174 IF U$="7" THEN GOTO 850
175 IF U$="8" THEN GOTO 200
176 IF U$="9" THEN GOTO 900
180 GOTO 150
200 CLS
205 GOSUB 1300
208 PRINT
210 PRINT "WHICH FILE DO YOU NEED CLOSED ?"
215 INPUT I
220 FOR J=1 TO 60
225 LET D(I,J)=0
230 NEXT J
235 LET N(I)=0
240 LET Q$(I)=""
250 GOTO 100
300 CLS
305 LET I=0
310 LET I=I+1
320 IF N(I)=0 THEN GOTO 330
325 GOTO 310
330 PRINT "WHAT IS THE TITLE OF FILE ";I
335 INPUT Q$(I)
340 PRINT TAB 4;Q$(I)
350 PRINT "HOW MANY POINTS WILL YOU ENTER INTO FILE NUMBER ";I;" ?"
360 INPUT N(I)
363 IF N(I)>60 THEN PRINT " %O%N%L%Y% %6%0% %P%O%I%N%T%S% %C%A%N% %B%E% %E%N%T%E%R%E%D%."
366 IF N(I)>60 THEN GOTO 350
370 CLS
380 LET J=0
390 LET J=J+1
395 IF J=N(I)+1 THEN GOTO 100
400 GOSUB 1000
405 GOTO 390
450 CLS
453 GOSUB 1300
456 PRINT
460 PRINT "ENTER DATA INTO WHICH FILE NO.?"
465 INPUT I
467 CLS
470 PRINT "NUMBER ";I;" IS ";Q$(I)
475 PRINT
480 PRINT N(I);" POINTS HAVE BEEN ENTERED."
485 LET J=N(I)
490 PRINT "%H%O%W% %M%A%N%Y% %M%O%R%E% %P%O%I%N%T%S% %D%O% %Y%O%U% %W%I%S%H %T%O% %E%N%T%E%R% %?"
500 INPUT A
505 LET N(I)=N(I)+A
510 IF N(I)>60 THEN GOTO 530
512 CLS
515 GOTO 390
530 LET N(I)=N(I)-A
535 PRINT "%O%N%L%Y% %6%0% %P%O%I%N%T%S% %C%A%N% %B%E% %E%N%T%E%R%E%D"
540 GOTO 475
550 CLS
555 GOSUB 1300
570 GOTO 1800
600 CLS
602 GOSUB 1300
604 PRINT
605 PRINT "CORRECTION IN WHICH FILE NUMBER?";
610 INPUT I
620 GOSUB 1400
625 PRINT
630 PRINT
640 PRINT "WHICH POINT NUMBER IS INCORRECT ?";
645 INPUT J
650 PRINT J
655 PRINT "WHAT IS THE CORRECT DATA ?"
660 INPUT D(I,J)
670 GOSUB 1200
680 GOTO 100
700 CLS
703 GOSUB 1300
704 PRINT
705 PRINT "WHICH FILE NUMBER DO YOU WANT LISTED ?";
710 INPUT I
715 GOSUB 1400
720 GOTO 1800
750 CLS
753 GOSUB 1300
755 PRINT
760 PRINT "WHICH FILE NUMBER DO YOU WANT GRAPHED ?"
765 INPUT I
770 GOTO 1500
850 CLS
860 PRINT AT 3,1;"%D%O% %Y%O%U% %N%E%E%D% %T%O% %R%E%T%U%R%N% %T%O% %M%E%N%U% %?"
862 PRINT TAB 12;"%(%Y% %O%R% %N%)"
865 PRINT AT 7,5;"IF %N IS TOUCHED THEN THE"
867 PRINT AT 9,1;"%D%A%T%A% %S%T%O%R%A%G%E% %A%N%D% %D%I%S%P%L%A%Y% %S%Y%S%T%E%M"
868 PRINT AT 11,9;"WILL BE SAVED."
870 GOSUB 1900
875 LET A$="DS AND DS"
880 IF U$="N" THEN SAVE A$
890 GOTO 100
900 CLS
910 PRINT AT 4,0;"%D%O% %Y%O%U% %N%E%E%D% %T%O% %R%E%T%U%R%N% %T%O% %M%E%N%U% %?"
913 PRINT TAB 12;"%(%Y% %O%R% %N%)"
920 PRINT
925 PRINT "IF %N IS TOUCHED THEN THE PROGRAM";TAB 12;"WILL %E%N%D."
930 GOSUB 1900
940 IF U$<>"N" THEN GOTO 100
945 PRINT
950 PRINT "%T%H%E% %P%R%O%G%R%A%M% %H%A%S% %E%N%D%E%D"
955 PRINT
960 PRINT "ENTER %G%O%T%O% %5%0 IF NEED TO CONT."
970 STOP
\n1000 PRINT AT 0,0;" ";
\n1010 PRINT " FILE ";I;" IS ";Q$(I);" "
\n1020 PRINT "CURRENT RANGE IS ";D(I,L(I));" TO ";D(I,H(I))
\n1035 SCROLL
\n1040 PRINT "WHAT IS DATA POINT-";J
\n1045 INPUT D(I,J)
\n1050 GOSUB 1200
\n1060 PRINT AT 21,0;" DATA POINT ";J;" IS ";D(I,J)
\n1070 RETURN
\n1200 IF D(I,J)>D(I,H(I)) THEN LET H(I)=J
\n1210 IF D(I,J)<D(I,L(I)) THEN LET L(I)=J
\n1220 RETURN
\n1300 LET I=0
\n1305 PRINT TAB 10;"%F%I%L%E% %T%I%T%L%E%S"
\n1310 LET I=I+1
\n1320 IF I=F+1 THEN RETURN
\n1330 PRINT I;"-";Q$(I);
\n1335 LET I=I+1
\n1340 IF I=F+1 THEN RETURN
\n1345 PRINT TAB 16;I;"-";Q$(I)
\n1350 GOTO 1310
\n1400 CLS
\n1402 LET V=0
\n1404 FOR J=1 TO N(I)
\n1406 LET V=V+D(I,J)
\n1408 NEXT J
\n1410 PRINT AT 1,4;"FILE NUMBER ";I;" IS ";Q$(I)
\n1415 PRINT "RANGE IS FROM ";D(I,L(I));" TO ";D(I,H(I))
\n1417 PRINT "DATA MEAN=";V/N(I);" SUM=";V
\n1418 PRINT
\n1420 LET J=1
\n1425 PRINT J;"=";D(I,J);
\n1430 IF J=N(I) THEN RETURN
\n1440 LET J=J+1
\n1446 PRINT TAB 8;J;"=";D(I,J);
\n1448 IF J=N(I) THEN RETURN
\n1450 LET J=J+1
\n1456 PRINT TAB 16;J;"=";D(I,J);
\n1458 IF J=N(I) THEN RETURN
\n1460 LET J=J+1
\n1466 PRINT TAB 24;J;"=";D(I,J)
\n1468 IF J=N(I) THEN RETURN
\n1470 LET J=J+1
\n1475 GOTO 1425
\n1500 LET V=0
\n1502 FOR J=1 TO N(I)
\n1505 LET E(J)=D(I,J)
\n1507 LET V=V+D(I,J)
\n1508 GOSUB 1200
\n1510 NEXT J
\n1520 LET X=E(H(I))-E(L(I))
\n1523 IF X=0 THEN PRINT "ALL DATA EQUAL:CANNOT BE GRAPHED"
\n1528 IF X=0 THEN GOTO 1800
\n1530 IF X>37 THEN LET Z=1
\n1533 IF X>=24 AND X<=37 THEN GOTO 1600
\n1536 IF X<24 THEN LET Z=2
\n1540 FOR J=1 TO N(I)
\n1550 IF Z=1 THEN LET E(J)=E(J)/1.5
\n1555 IF Z=2 THEN LET E(J)=E(J)*1.5
\n1560 NEXT J
\n1570 GOTO 1520
\n1600 CLS
\n1610 PRINT "FILE ";I;" IS ";Q$(I);" :SUM=";V
\n1620 PRINT " LOW=";D(I,L(I));" HIGH=";D(I,H(I));" MEAN=";V/N(I)
\n1625 PRINT " CLOSING=";D(I,N(I));" (NUMBER ";N(I);" )"
\n1628 PRINT AT 0,0;""
\n1630 FOR K=1 TO 19
\n1631 PRINT "\: "
\n1633 NEXT K
\n1635 SLOW
\n1637 PRINT AT 20,0;"\''1\''\''\''10\''\''\''20\''\''\''30\''\''\''40\''\''\''50\''\''\''60"
\n1640 FOR J=1 TO N(I)
\n1650 FOR K=4 TO (INT (E(J)-E(L(I))+4))
\n1655 PLOT J+1,K
\n1660 NEXT K
\n1665 NEXT J
\n1668 FAST
\n1670 GOTO 1800
\n1800 PRINT AT 21,1;"%P%R%E%S%S% %E%N%T%E%R% %T%O% %R%E%T%U%R%N% %T%O% %M%E%N%U"
\n1810 INPUT K$
\n1820 GOTO 100
\n1900 SLOW
\n1903 IF INKEY$<>"" THEN GOTO 1903
\n1905 IF INKEY$="" THEN GOTO 1905
\n1910 LET U$=INKEY$
\n1915 FAST
\n1920 RETURN
\n2000 PRINT AT 8,3;"THIS IS THE INITIALIZATION"
\n2010 PRINT AT 10,4;"TO DIMENSION THE MEMORY."
\n2020 PRINT AT 13,5;"ENTER %G%O%T%O% %5%0 TO CONT."
\n2030 LET F=25
\n2040 DIM D(F,60)
\n2043 DIM E(60)
\n2045 DIM H(F)
\n2046 DIM N(F+1)
\n2049 DIM Q$(F,10)
\n2050 DIM L(F)
\n2052 FOR I=1 TO F
\n2055 LET L(I)=1
\n2058 LET H(I)=1
\n2060 NEXT I
\n2090 STOP
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

