Magazine Index

This file is part of and Timex Sinclair Public Domain Library Tape 1007. Download the collection to get this file.
Date: 198x
Type: Program
Platform(s): TS 1000
Tags: Database

This program implements a simple flat-file database for cataloguing projects with associated magazine references, storing up to five records each containing a project name (25 chars), magazine (16 chars), month/year (6 chars), page number (4 chars), and remarks (30 chars). The main menu uses `GOTO 1000*VAL I$` to dispatch between four options — data entry, viewing/editing, file clear, and tape save — using arithmetic on the menu choice character. Record entry uses five parallel string arrays (`P$`, `M$`, `D$`, `R$`, `N$`) dimensioned with a common variable `T=5`, and a counter `R1` tracks how many records have been entered. The editing sub-menu at line 2700 uses `GOTO 2800+(VAL Y$*10)` to jump to field-specific edit routines via computed branching. The display alternates between `FAST` and `SLOW` modes throughout to balance rendering speed with input responsiveness.


Program Analysis

Program Structure

The program is organised around a main menu (lines 100–230) that dispatches to four functional sections using a computed GOTO. Lines 1000–1920 handle data entry, lines 2000–2999 cover viewing and editing, line 3000 performs a RUN (file clear by restart), and lines 4000–4080 manage tape saving.

Line RangeFunction
4–90Initialisation: array dimensions, counter reset
100–230Main menu display and dispatch
1000–1920Data entry loop
2000–2999View, search, and edit records
3000“Clear file” via RUN
4000–4080Tape save routine

Data Model

Five parallel string arrays hold the database fields, all dimensioned to T=5 rows at startup:

  • P$(T,25) — Project name (25 characters)
  • M$(T,16) — Magazine name (16 characters)
  • D$(T,6) — Month/Year (6 characters)
  • N$(T,4) — Page number (4 characters)
  • R$(T,30) — Remarks (30 characters)

The variable R1 tracks how many records have been populated. Entry begins at N=R1+1, so re-entering the entry routine appends rather than overwrites. Pressing Enter on an empty project field at line 1055 exits the loop and sets R1=N-1.

Computed GOTO Dispatch

The main menu validates that CODE I$ falls between 29 and 32 (the ZX81 key codes for digits 1–4) then executes GOTO 1000*VAL I$ at line 230. This cleanly maps menu choices to section start lines without an IF-chain. A similar technique appears in the edit sub-menu at line 2750: GOTO 2800+(VAL Y$*10) routes choices 1–5 to lines 2810, 2820, 2830, 2840, and 2880 respectively — note that 2850–2870 are absent, so choice 5 (Remarks) lands at 2880 rather than 2850, which is intentional.

FAST/SLOW Mode Alternation

The program switches between FAST and SLOW modes frequently. FAST is used for screen-clearing and rendering to avoid flicker, while SLOW is engaged immediately before INPUT or INKEY$ polling loops to allow the display to remain stable during user interaction. This pattern repeats throughout all four functional sections.

Key BASIC Idioms

  • Inverse-video banner: Lines 110–115 use block graphic escapes to draw a bordered title box with a solid top bar, inverse-video text, and a bottom border made of characters.
  • INKEY$ polling loop: Lines 200–210 and 2020–2060 implement a spin-wait on INKEY$ with validation against allowed key codes, a standard ZX81 idiom for menu selection.
  • SCROLL for output management: The entry routine (lines 1010–1800) uses repeated SCROLL calls rather than CLS to create a rolling display of field prompts and entered values.
  • Substring comparison for search: Line 2170 uses X$( TO LEN I$) to match only the leading characters of a stored project name against the search string, providing a simple prefix search.
  • File clear via RUN: Option 3 jumps to line 3000 which contains only RUN, restarting the program and thus reinitialising all arrays — a common minimal “clear” technique.

Notable Anomalies and Observations

  • Line 155 prints a warning in inverse video: “NEVER ENTER RUN-ENTER GOTO 102”, instructing the user to use GOTO 102 instead of RUN to return to the menu without losing data — since RUN would reinitialise all arrays.
  • Line 180 immediately overwrites the normal text printed at line 170 with an inverse-video version of the same string (“ENTER ONE OF ABOVE”), creating an inverse prompt effect without clearing the screen.
  • The edit field dispatch via GOTO 2800+(VAL Y$*10) accepts codes 29–36 (digits 1–8) but only defines handlers at 2810–2880 for five fields. Choices 6, 7, or 8 would jump to non-existent lines 2860, 2870, or 2880 — where 2880 happens to be the Remarks handler. Choices 6 and 7 would cause an error.
  • Lines 4060–4080 appear after the tape save routine and are unreachable in normal execution: CLEAR followed by SAVE "1032%9" (saving under an inverse-character filename) and RUN. These lines appear to be a bootstrap or master save remnant left in the listing.
  • The database capacity is fixed at T=5 records. Increasing T at line 5 is the only way to expand capacity, constrained by available RAM.

Content

Appears On

Assembled by Tim Ward from many sources. Contains programs 10294-10335.

Related Products

Related Articles

Related Content

Image Gallery

Source Code

   4 FAST 
   5 LET T=5
  10 DIM P$(T,25)
  20 DIM M$(T,16)
  30 DIM D$(T,6)
  40 DIM N$(T,4)
  80 DIM R$(T,30)
  90 LET R1=0
 100 FAST 
 102 CLS 
 105 PRINT "   :'''''''''''''''''''''''''''''''''''''''''''''''''':"
 110 PRINT "   : %N%A%M%E% %A%N%D% %A%D%D%R%E%S%S% %P%R%O%G%R%A%M :"
 115 PRINT "   :..................................................:"
 120 PRINT ,,,,,,,,,,"    TO ENTER OR ADD DATA  - 1"
 130 PRINT "    TO SEE OR CHANGE DATA - 2"
 140 PRINT "    TO CLEAR FILE         - 3"
 150 PRINT "    TO SAVE FILE ON TAPE  - 4"
 155 PRINT AT 15,1;"%N%E%V%E%R% %E%N%T%E%R% %R%U%N%-%E%N%T%E%R% %G%O%T%O% %1%0%2"
 160 PRINT AT 19,6;":'''''''''''''''''''''''''''''''''''''':";AT 20,6;": ";AT 20,25;" :";AT 21,6;":......................................:"
 170 PRINT AT 20,7;"ENTER ONE OF ABOVE"
 180 PRINT AT 20,7;"%E%N%T%E%R% %O%N%E% %O%F% %A%B%O%V%E"
 190 SLOW 
 200 LET I$=INKEY$
 210 IF CODE I$<29 OR CODE I$>32 THEN GOTO 170
 215 FAST 
 220 CLS 
 230 GOTO 1000*VAL I$
 1000 FOR N=R1+1 TO T
 1010 SCROLL 
 1020 PRINT "NO.";N;" PROJECT ? (25)"
 1030 SLOW 
 1040 INPUT X$
 1050 FAST 
 1055 IF X$="" THEN GOTO 1900
 1057 LET P$(N)=X$
 1060 SCROLL 
 1070 PRINT P$(N)
 1080 SCROLL 
 1090 SCROLL 
 1100 SCROLL 
 1110 PRINT "MAGAZINE ? (16)"
 1120 SLOW 
 1130 INPUT M$(N)
 1140 FAST 
 1150 SCROLL 
 1160 PRINT M$(N)
 1170 SCROLL 
 1180 SCROLL 
 1200 SCROLL 
 1210 PRINT "MONTH/YR ? (6)"
 1220 SLOW 
 1230 INPUT D$(N)
 1240 FAST 
 1250 SCROLL 
 1260 PRINT D$(N)
 1270 SCROLL 
 1280 SCROLL 
 1300 SCROLL 
 1310 PRINT "PAGE NO.? (4)"
 1320 SLOW 
 1330 INPUT N$(N)
 1340 FAST 
 1350 SCROLL 
 1360 PRINT N$(N)
 1370 SCROLL 
 1380 SCROLL 
 1400 SCROLL 
 1710 PRINT "REMARKS ? (30)"
 1720 SLOW 
 1730 INPUT R$(N)
 1740 FAST 
 1750 SCROLL 
 1760 PRINT R$(N)
 1770 SCROLL 
 1780 SCROLL 
 1800 NEXT N
 1810 GOTO 100
 1900 LET R1=N-1
 1910 SLOW 
 1920 GOTO 100
 2000 CLS 
 2005 SLOW 
 2010 PRINT AT 11,2;"DO YOU WANT TO SEE THE WHOLE";AT 12,14;"FILE?"
 2020 LET I$=INKEY$
 2030 IF I$="" THEN GOTO 2020
 2040 IF I$="Y" THEN GOTO 2500
 2050 IF I$="N" THEN GOTO 2100
 2060 GOTO 2020
 2100 FAST 
 2110 CLS 
 2120 PRINT AT 11,5;"WHAT IS THE PROJECT ?"
 2130 SLOW 
 2140 INPUT I$
 2145 FAST 
 2150 FOR N=1 TO R1
 2160 LET X$=P$(N)
 2170 IF I$=X$( TO LEN I$) THEN GOTO 2300
 2180 NEXT N
 2185 CLS 
 2190 PRINT AT 11,6;"PROJECT NOT IN FILE?";AT 21,0;"PRESS ENTER TO CONTINUE :::::"
 2195 SLOW 
 2200 INPUT I$
 2210 GOTO 100
 2300 FAST 
 2310 CLS 
 2320 PRINT M$(N);TAB 32;P$(N);TAB 32;D$(N);TAB 32;N$(N);TAB 32;,,R$(N)
 2330 PRINT AT 21,0;"IS THIS THE CORRECT PROJECT ?"
 2335 SLOW 
 2340 LET Y$=INKEY$
 2350 IF Y$="" THEN GOTO 2340
 2360 IF Y$="Y" THEN GOTO 2600
 2370 IF Y$="N" THEN GOTO 2180
 2380 GOTO 2340
 2500 FAST 
 2510 CLS 
 2520 FOR N=1 TO R1
 2530 FAST 
 2535 CLS 
 2540 PRINT "PROJECT NO.";N;" OF ";R1,,,,,
 2550 PRINT M$(N);TAB 32;P$(N);TAB 32;D$(N);TAB 32;N$(N);TAB 32;,,R$(N);AT 21,0;"PRESS ENTER TO CONTINUE :::"
 2560 SLOW 
 2570 INPUT I$
 2580 NEXT N
 2590 GOTO 100
 2600 FAST 
 2610 PRINT AT 21,0;"DO YOU WANT TO EDIT?       "
 2620 SLOW 
 2630 LET Y$=INKEY$
 2640 IF Y$="" THEN GOTO 2630
 2650 IF Y$="N" THEN GOTO 100
 2660 IF Y$="Y" THEN GOTO 2700
 2670 GOTO 2630
 2700 PRINT AT 11,0;"1 - PROJECT","2 - MAGAZINE","3 - MONTH/YR","4 - PAGE NO.","5 - REMARKS"
 2710 PRINT AT 21,0;"WHICH ONE DO YOU WISH TO EDIT?"
 2720 LET Y$=INKEY$
 2730 IF Y$="" THEN GOTO 2720
 2740 IF CODE Y$<29 OR CODE Y$>36 THEN GOTO 2720
 2750 GOTO 2800+(VAL Y$*10)
 2810 PRINT AT 19,0;"OLD PROJECT IS";TAB 32;P$(N);TAB 32;"INPUT NEW INFO :::            "
 2815 INPUT P$(N)
 2817 GOTO 2900
 2820 PRINT AT 19,0;"OLD MAGAZINE IS";TAB 32;M$(N);TAB 32;"INPUT NEW INFO :::            "
 2825 INPUT M$(N)
 2827 GOTO 2900
 2830 PRINT AT 19,0;"OLD MONTH/YR IS";TAB 32;D$(N);TAB 32;"INPUT NEW INFO :::            "
 2835 INPUT D$(N)
 2837 GOTO 2900
 2840 PRINT AT 19,0;"OLD PAGE NO. IS";TAB 32;N$(N);TAB 32;"INPUT NEW INFO :::            "
 2845 INPUT N$(N)
 2847 GOTO 2900
 2880 PRINT AT 19,0;"OLD REMARKS ARE";TAB 32;R$(N);TAB 32;"INPUT NEW INFO :::            "
 2885 INPUT R$(N)
 2900 FAST 
 2910 CLS 
 2920 PRINT M$(N);TAB 32;P$(N);TAB 32;D$(N);TAB 32;N$(N);TAB 32;,,R$(N)
 2930 GOTO 2610
 2999 GOTO 2999
 3000 RUN 
 4000 FAST 
 4010 PRINT "WHAT IS THE NAME OF THE FILE?"
 4015 SLOW 
 4020 INPUT B$
 4030 PRINT ,,,,"PREPARE THE RECORDER AND THEN","PRESS ENTER ::::"
 4035 INPUT X$
 4040 SAVE B$
 4050 GOTO 100
 4060 CLEAR 
 4070 SAVE "1032%9"
 4080 RUN 

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

People

No people associated with this content.

Scroll to Top